public static void main(String[] args) {
JSONArray jsar = new JSONArray();
JSONObject jsob = new JSONObject();
jsob.put("Name", "john");
jsob.put("Age", "21");
System.out.println(jsob);
jsar.add(0,jsob);
jsob.put("Name", "nimal");
jsob.put("Age", "25");
System.out.println(jsob);
jsar.add(1,jsob);
System.out.println(jsar);
}
{"Age":"21","Name":"john"}
{"Age":"25","Name":"nimal"}
[{"Age":"25","Name":"nimal"},{"Age":"25","Name":"nimal"}]
any help me please why the object with name john is not added to the json array