I've a json file like :
{
"a1" : {
"Contestant 1 marks" : 44,
"Contestant 10 marks" : 30,
"Contestant 11 marks" : 15,
"Contestant 12 marks" : 35,
"Contestant 13 marks" : 28,
"Contestant 14 marks" : 8,
"Contestant 2 marks" : 35,
"Contestant 3 marks" : 30.899999618530273,
"Contestant 4 marks" : 39,
"Contestant 5 marks" : 45,
"Contestant 6 marks" : 47,
"Contestant 7 marks" : 17,
"Contestant 8 marks" : 37,
"Contestant 9 marks" : 35
},
"a2" : {
"Contestant 1 marks" : 35,
"Contestant 10 marks" : 30,
"Contestant 11 marks" : 15,
"Contestant 12 marks" : 35,
"Contestant 13 marks" : 28,
"Contestant 14 marks" : 8,
"Contestant 2 marks" : 30,
"Contestant 3 marks" : 30.899999618530273,
"Contestant 4 marks" : 39,
"Contestant 5 marks" : 45,
"Contestant 6 marks" : 47,
"Contestant 7 marks" : 17,
"Contestant 8 marks" : 37,
"Contestant 9 marks" : 35
}
}
It seems like there are two JSON objects here a1, a2. And these objects itself have 14 JSON objects.
I've a String completeJson;
which contains complete JSON.
Now when I write
JSONObject jsonRootObj = new JSONObject(completeJson);
Then whilch json object will come into jsonRootObj?
Also how do I get the value for the key : "Contestant 1 marks" for a1 and a2 in my JSON file ?
I want to add the value of objects in a1
with value of objects in a2
which have the same KEY.