この json オブジェクトは非常に大きくなることがあります。GSON で解析したいのですが、Java オブジェクトを解析するための形式がよくわかりません。
このオブジェクトが与えられた場合、gson.fromJSON メソッドでデータを保持するために Java モデル オブジェクトをどのように形成すればよいでしょうか。現在のオブジェクトが「null」でいっぱいになる
一番下のオブジェクトのシンプルさを説明します
{
response: {
user_is_following: 0,
name: "Tennesee",
submitted_requests: 429,
completed_requests: 34,
request_types: {
c_id: 1064,
request_types: [
{
objectKey: {
id: 15699,
name: "Complaint",
has_custom_fields: 0,
disable_title: 0,
disable_description: 0,
force_private: 0,
image: null
}
},
{
objectKey: {
id: 15700,
name: "Compliment",
has_custom_fields: 0,
category_id: 605,
disable_title: 0,
disable_description: 0,
force_private: 0,
image: null
}
},
{
objectKey: {
id: 17574,
name: "Custom Fields, all of them",
has_custom_fields: 1,
disable_title: 0,
disable_description: 0,
force_private: 0,
image: null,
custom_fields: [
{
custom_field: {
id: "1663",
name: "I'm a text input",
description: "I'm a text input description",
type: "text",
required: 1,
is_public: 1,
options: [
]
}
},
{
custom_field: {
id: "1664",
name: "I'm a text input display only",
description: "I'm a text input display only description",
type: "display",
required: 0,
is_public: 0,
options: [
]
}
},
{
custom_field: {
id: "1665",
name: "I'm a checkbox",
description: "I'm a checkbox description",
type: "checkbox",
required: 0,
is_public: 1,
options: [
]
}
},
{
custom_field: {
id: "1666",
name: "I'm a single select",
description: "I'm a single select description",
type: "singleselect",
required: 1,
is_public: 0,
options: [
{
option: {
id: "3751",
name: "A 123 !@@#",
description: "A 123 !@@# description"
}
},
{
option: {
id: "3752",
name: "B ",
description: "B description"
}
},
{
option: {
id: "3753",
name: "C",
description: "C description"
}
},
{
option: {
id: "3754",
name: " D",
description: "D description"
}
}
]
}
},
}
],
s_types: [
],
categories: [
{
category: {
id: 618,
client: 1064,
name: "Abc",
gov_creator: 1841,
description: "",
parent: 607,
date_created: 1368137256,
image: null
}
},
{
category: {
id: 602,
client: 1064,
name: "Animal Control",
gov_creator: 2275,
description: "",
parent: null,
date_created: 1367878768,
image: null
}
},
}
],
assets: [
],
benchmark: 0.36078095436096
},
status: {
type: "success",
message: "Success",
code: 200,
code_message: "Ok"
}
}
}
本当の肉はrequest_types
、JSONArray である 2 番目のキーにあります。各インデックスにはオブジェクトが含まれ、各オブジェクトCustom Fields
には json 配列であるキーを含めることができ、場合によってはoptions
json 配列を含めることができます。
私はこれらすべて、異なる解析パラダイムのモデルを持っていますが、GSON のモデルは持っていません。メモリの制限により、今すぐ GSON を使用する必要があります