gpt4 book ai didi

java - 我应该如何定义我的模型类以与 Gson 进行安排?

转载 作者:行者123 更新时间:2023-12-02 06:17:18 27 4
gpt4 key购买 nike

我有以下 JSON:

  {
_id: "5252fdf424f1e7fbf7000004",
address: "Calle 1000",
city: "Concepción",
created_at: "2013-10-07T18:31:19.375Z",
description: "",
name: "Joctos",
phone: "94967994",
updated_at: "2013-12-09T13:03:07.328Z",
happy_hour: {
active: false,
type: 1,
all_day: false,
start: "2013-12-17T03:30:00.000Z",
end: "2013-12-17T05:00:00.000Z"
}
}

告诉他们接收并使用 JSON GSON 我相信一个对象,问题是定义了对象如下

public class StoreModel {

@SerializedName("_id")
private String _id;

@SerializedName("address")
private String address;

@SerializedName("city")
private String city;

@SerializedName("created_at")
private String created_at;

@SerializedName("description")
private String description;

@SerializedName("name")
private String name;

@SerializedName("phone")
private String phone;

@SerializedName("updated_at")
private String updated_at;

public String get_id() {
return this._id;
}

public void set_id(String _id) {
this._id = _id;
}

public String getAddress() {
return this.address;
}

public void setAddress(String address) {
this.address = address;
}

public String getCity() {
return this.city;
}

public void setCity(String city) {
this.city = city;
}

public String getCreated_at() {
return this.created_at;
}

public void setCreated_at(String created_at) {
this.created_at = created_at;
}

public String getDescription() {
return this.description;
}

public void setDescription(String description) {
this.description = description;
}

public String getName() {
return this.name;
}

public void setName(String name) {
this.name = name;
}

public String getPhone() {
return this.phone;
}

public void setPhone(String phone) {
this.phone = phone;
}

public String getUpdated_at() {
return this.updated_at;
}

public void setUpdated_at(String updated_at) {
this.updated_at = updated_at;
}

}

我应该如何定义模型来获取“happy_hours”数据?

最佳答案

StoreModel 类将包含 happy_hours 对象

关于java - 我应该如何定义我的模型类以与 Gson 进行安排?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21341578/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com