We have a complex json structure which we need to parse in Android.
{
"StatusCode":0,
"StatusInfo":"Processed and Logged OK",
"Schools":[
{
"Id":"1",
"Name":"School 1",
"Class":[
{
"Id":"11",
"Name":"Class 1",
"Section":[
{
"Id":"12",
"Name":"Section A"
},
{
"Id":"13",
"Name":"Section B"
},
{
"Id":"14",
"Name":"Section C"
}
]
},
{
"Id":"21",
"Name":"Class 2",
"Section":[
{
"Id":"22",
"Name":"Section A"
},
{
"Id":"23",
"Name":"Section B"
}
]
}
]
},
{
"Id":"5",
"Name":"School 2",
"Class":[
{
"Id":"51",
"Name":"Class 1",
"Section":[
{
"Id":"512",
"Name":"Section A"
},
{
"Id":"513",
"Name":"Section B"
},
{
"Id":"514",
"Name":"Section C"
}
]
},
{
"Id":"52",
"Name":"Class 2",
"Section":[
{
"Id":"522",
"Name":"Section A"
},
{
"Id":"523",
"Name":"Section B"
}
]
}
]
}
]
}
I’ve checked various tutorials on json parsing in Android, but i got confused with this structure as it re-use the names under various Arrays. I would like to check if it would be easy to use libraries like GSON / Jackson to parse this json structure.
Also, if this structure is big, will it occupy more memory and have performance issue while parsing this structure each time to find a node?
Regards,
Aravind. C
Gson is probably the best way to go.
If you are unsure how to build your java classes you can easily generate the classes with that json code you have online here -> JsonGen