Below Json format is my input, i need to count the total based on Object
Students:[
{
"Student_id": "101"
"Name": "Jon",
"Course" : "Engineer"
},
{
"Student_id": "102"
"Name": "Snow",
"Course" : "Medical"
},
{
"Student_id": "103"
"Name": "Walter",
"Course" : "Chemistry"
},
{
"Student_id": "104"
"Name": "White",
"Course" : "Chemistry"
}
]
When i loop the JsonArray Am not able to count the total?? it will show always count 1,i want output like below format
No Of Students: 4
Total Chemistry Students :2
Below code i tried,
JsonArray Students=Details.getAsJsonArray("Students");
for(int i=0;i<Students.size();i++)
{
JsonObject Std=Students.get(i).getAsJsonObject();
String SrdID=Std.get("Student_id").getAsString();
System.out.println("Student Details----"+SrdID);
}
String [] Studentarr=new String[] {"Student_id"};
int Count=Studentarr.length;
System.out.println("Count ---"+ Count);
Any Help will be Appreciate!! Thanks In Advance