I need to parse a json on android like:
{"header": {
"param": "param"
},
"body": {
"param": "1",
"param2": "2",
"param3": [
{
"param4": "4",
"param5": "5"
},
{
"param6": "6"
}
],
"param7": "7",
"param12": [
{
"param8": "8",
"param13": [
{
"param9": "9"
},
{
"param10": "10"
}
]
}
],
"param11": "11"
}
}
My code is:
org.json.simple.JSONObject LJsonObj = (org.json.simple.JSONObject) new JSONParser().parse(AString);
try {
JSONArray LBody = (JSONArray) LJsonObj.get("body");
result = LBody.toString();
LStrTemp = result;
} catch (Exception e) {
e.printStackTrace();
} finally {
LJsonObj.clear();
}
return result;
It breaks or does not work at all at the moment:
JSONArray LBody = (JSONArray) LJsonObj.get ("body");
How can I parse the body
tag?
Where is the error, tell me?
String, Integer, and other types are parsed without problems by this principle. And with json there are more complicated problems