Was trying to use the android JSON object to parse a particular response, but am unable to make a code that would parse this response "{"r":{"f":[1,0,15,5948]}}".
Tried using below code, but am getting error :
"No value for f : {"r":{"f":[1,0,15,5948]}}"
Code is as follows:
String abc = "{\"r\":{\"f\":[1,0,15,5948]}}";
JSONObject json = new JSONObject(abc);
if (json.has("r")) {
Bundle b = new Bundle();
b.putInt("p", json.getJSONArray("f").getInt(0));
b.putInt("s", json.getJSONArray("f").getInt(1));
}
I intend to parse the above response and get the values in bundle respective variables.
Like b.putInt("p", json.getJSONArray("f").getInt(0)); should get the 1 in f:[1....]
and so forth.
Can somebody help in having a working code for getting the values for above reponse.