I hava a Json like this:
{
"a_num":56.2,
"a_meter":"GM54",
"b_num":26.2,
"b_meter":"WM21",
"a":[
{"date":"2014\/03\/10","amount":52,"usage":32},
{"date":"2014\/02\/11","amount":12,"usage":84},
{"date":"2014\/01\/11","amount":142,"usage":23},
{"date":"2014\/08\/11","amount":78,"usage":34}],
"b":[
{"date":"2014\/07\/13","amount":511,"usage":322},
{"date":"2014\/02\/10","amount":111,"usage":22},
{"date":"2014\/03\/30","amount":311,"usage":332},
{"date":"2014\/01\/30","amount":51,"usage":32}]
}
How can I get 2 JsonArrays a and b.
Please help me with this.
I've tried this:
String aNum = json.getString("a_num");
String aMeter = json.getString("a_meter");
String bNum = json.getString("b_num");
String bMeter = json.getString("b_meter");
JSONArray listA = json.getJSONArray("a");
JSONArray listB = json.getJSONArray("b");
It throw exception:
org.json.JSONException: Value {"amount":52,"date":"2014\/03\/10","usage":32} at a of type org.json.JSONObject cannot be converted to JSONArray
JSONArray listA = json.getJSONArray("a");this is alright. Do you use listA further in your code. If so post the sameGsonparsing?,Gsonparsing is one of the bestJSONparsing I have ever experienced.