Find an item in the json object of the http response

0

Well I'm a "beginner" on android. And in my project, I'm picking up from http reponse (with the GET method) a string for JSONObject.

"{ "status":{ "d3": { "stats" : false },    "a1": { "stats" : false } } }"

But I'm not able to do the function that gets d3 / a1.

    
asked by anonymous 04.08.2017 / 22:43

1 answer

2

All you have to do is fetch the JSONObject and then fetch the first element as:

JSONObject obj = new JSONObject (stringJson);
JSONObject status = obj.getJSONObject("status");
JSONObject d3 = status.getJSONObject("d3");

And so you will be able to always get your values following this concept.

  

But I suggest that you search a little for how to convert Json to an object that will make your life a lot easier.

    
04.08.2017 / 23:16