Hello guys,
JSON is a collection of name/value pairs, and it's in various languages, JSON is like as an object, record, struct, dictionary, hash table, keyed list, or associative array. JSON is an ordered list of values and in many languages, it is realized as an array, vector, list, or sequence. JSONArray can store multiple JSONObject in various data types i.e int,boolean,String etc.
Below example will help you to create JSONArray.
JSONArray jsonArraylab=JSONFactoryUtil.createJSONArray();
for(int i =0; i<=10;i++){
JSONObject jsonObjlab = JSONFactoryUtil.createJSONObject();
jsonObjlab.put("labName","labName");
jsonObjlab.put("labid","labid";
jsonArraylab.put(jsonObjlab);
}
System.out.println("lab name "+jsonArraylab.toString());
0 Comment(s)