I am trying to iterate through my json file and get required details here is my json
{
"000": {
"component": "c",
"determinantType": "dt",
"determinant": "d",
"header": "h",
"determinantvalue": "null"
},
"001": {
"component": "t",
"determinantType": "i",
"determinant":"ld",
"header": "D",
"determinantvalue": "null"
},
"002": {
"component": "x",
"determinantType": "id",
"determinant": "pld",
"header": "P",
"determinantValue": "null"
}}
my java code
FileReader file = new FileReader("test.json");
Object obj = parser.parse(file);
System.out.println(obj);
JSONObject jsonObject = (JSONObject) obj;
JSONArray msg = (JSONArray) jsonObject.get(key);
Iterator<String> iterator = msg.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
String component = (String) jsonObject.get("component");
System.out.println("component: " + component);
As you can see in the code I am importing my json file and trying to get next elements and printing components out of it , I should also print header,determinant and determinant value as well Thank you