I have this Json structured file, which validates as a Json file.
I need to parse this Json data using Java code. I have tried several libraries like json.org and simple Jason but I can't quite get the values from the Json file error like invalid s
{
"capacity": "30",
"participants": {
"858113": {
"studentNum": "R1506D858113",
"module_id": "300",
"offer_id": "4254",
"grade": null,
"code": "WA"
},
"1007938": {
"studentNum": "R1509D1007938",
"module_id": "300",
"offer_id": "4254",
"grade": null,
"code": "WA"
},
"1022146": {
"studentNum": "R1509D1022146",
"module_id": "300",
"offer_id": "4254",
"grade": null,
"code": "WA"
},
"1041591": {
"studentNum": "R1510D1041591",
"module_id": "300",
"offer_id": "4254",
"grade": null,
"code": "WA"
},
"1226958": {
"studentNum": "R1601D1226958",
"module_id": "300",
"offer_id": "4254",
"grade": null,
"code": "WA"
}
}
}
This is the Jason file and below code using json.org
final JSONObject obj = new JSONObject(JSON_DATA);
final JSONArray participants = obj.getJSONArray("participants");
final int n = participants.length();
for (int i = 0; i < n; ++i) {
final JSONObject person = participants.getJSONObject(i);
System.out.println(person.getInt("studentNum"));
}
Basically I need to retrieve this this information as an array.