I am new to JSON parsing and I would need your kind help to understand how to parse a JSON object inside an Array.
My JSON structure log is below:
{A:"text",B:"text",C:[{T:"Text",D:{E:"Text",F:{G:"time"}},H:{I:"200"},J:{K:{L:53,M:2.2},N:"Text"},P:{Q:"Time"}}]}
log is my input JSON as above.
JSONObject logJson = (JSONObject) JSONSerializer.toJSON( log );
String a = logJson.getString("A");
String b = logJson.getString("B");
Now question is how do I parse into the Array and get JSONObject. I am using net.sf API.
First of all, I think your json format is invalid.
The “key” must stand in ” as well e.g.
"A":"text"You can get the “C” Array by using
JSONArray jsonArray = logJson.getJSONArray("C");On the array you can iterate: