This json object can be very very large sometimes, I would like to parse it with GSON but I do not quite get how the format of my java objects should be to parse them.
What would really help me are some very contextual examples, given this object, how would I form my java model objects to hold the data in a gson.fromJSON method? My current objects get filled with "null"
I explain the simplicity of the object at the bottom
{
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"
}
}
}
The real meat is in the request_types
key, the second one, which is a JSONArray. Each index contains an object, each object can contain a Custom Fields
key which is a json array as well, which in some cases can contain an options
json array.
I have models for all of these, for a different parsing paradigm, but not for GSON. I will need to use GSON now because of memory limitations