I have exising json data which contains json array:
{
"dataSetId":3,
"Viewable":null,
"Charge":null,
"tax":null,
"Cards":[ //need to remove or update json array Cards here
{
"Id":605,
"startCount":1,
"endCount":500,
"Party":0.25,
"non-Party":0.375,
"X-Party":1.25,
"Y-Party":1.625
},
{
"Id":605,
"startCount":1,
"endCount":500,
"Party":0.28,
"non-Party":0.377,
"X-Party":1.26,
"Y-Party":1.626
}]
}
Now, i want to insert the new json array created at Json Element Cards above. Following i tried :
JsonObject orignalJson = gson.fromJson(existingJson.asString(), JsonElement.class).getAsJsonObject();
System.out.println("orignalJson :: "+orignalJson);
JsonObject dataElementJson = orignalJson.get("data").getAsJsonObject();
JsonArray RateJsonArray = dataElementJson.get("Cards").getAsJsonArray();
How the index is identified in orignaljson and update Cards (Json Array)?