I want to have an output like this
{"content":{
"A":["a1","a2","a3"],
"B":"b1String",
"C":["c1","c2"]}}
As of now, I am getting this.
{"content":{
"A":"[a1, a2, a3]",
"C":"[c1, c2]",
"B":"b1String"}}
Below is my code
Map <String, Object> myMap = new HashMap<String, Object>();
myMap.put("A",arrayOfA); //which is ArrayList<String>
myMap.put("B", myB1String);//which is String
myMap.put("C", arrayOfC);//which is ArrayList<String>
JSONObject jsonAll = new JSONObject(myMap);
Map <String, Object> mapAll = new HashMap<String, Object>();
mapAll.put("content", jsonAll);
JSONObject finalObject=new JSONObject(mapAll);
Log.e("JSON", finalObject.toString());
Any help woulld be much appreciated. Thanks