I have the following JSON:
{
data: [
{
objectType: "ServiceForbiddenException",
item: {
service: "users",
action: "index",
code: 403,
message: "Access to the service [users] is forbidden."
}
}
]
}
I tried parsing it using the following snippet:
String bodyData = iRes.body().string();
try{
JSONObject body = new JSONObject(bodyData);
JSONArray data = body.getJSONArray("data");
JSONObject type = data.getJSONObject(0);
JSONArray item = data.getJSONArray(1);
}
catch (Exception e)
{
e.printStackTrace();
}
the problem is that is that JSONArray data = body.getJSONArray("data");is actually the whole data, and not an array.
How do I parse it correctly? are there better libs / ways to parse a json in Java (Android)
".