I tried to parse multiple JSON arrays that my server returns to my application.
The structure of the returned message from the server looks like this:
[ json objects ][ json objects ]
returned message :
[{"latitude":"44.33","longitude":"44.33","name":"test1","Notification":"true"}][{"latitude":"44.33","longitude":"44.33","name":"test2","Notification":"false"}]
Now I tried to parse this and get the Notification status (true / false) but I did not get the item i needed.
try {
JSONArray jr = new JSONArray(answer);
JSONObject jb = (JSONObject)jr.getJSONObject(0);
JSONArray nof = jb.getJSONArray("Notification");
Log.d("Json", String.valueOf(nof));
}catch(Exception e)
{
e.printStackTrace();
}
I would be happy if someone can help me to understand what I need todo to achieve my mission.
String nof = jb.getString("Notification");instead ofJSONArray nof = jb.getJSONArray("Notification");and to print you can simply print value of nof likeLog.d("Json", nof);