I am trying to create this JSON object on android. I am stuck on how to add a string array in the object.
A = {
\"class\" : \"4\" ,
\"name\" : [\"joh
@bhavindesai's, answer is great answer. Here is another way to solve this issue. You can simply do it using Json Simple library. Here is the gradle
compile 'com.googlecode.json-simple:json-simple:1.1'
Here is sample code:
org.json.simple.JSONObject jsonObject=new org.json.simple.JSONObject();
jsonObject.put("Object","String Object");
ArrayList list = new ArrayList();
list.add("john");
list.add("mat");
list.add("jason");
list.add("matthew");
jsonObject.put("List",list);
That's it. :)