I would like to create JSON format and I have some problem about this
I have no idea to create Jsonarray and JsonObject in JsonObject
{
"users": [7, 16, 35],
"group_id": "sdkfjsdkljflds"
}
I try
JSONObject jsonParams = new JSONObject();
try {
jsonParams.put("group_id", "dlfsdds");
jsonParams.put("users", list);
} catch (JSONException e) {
e.printStackTrace();
}
and my log is show
{
"users":"[7, 16, 35]",
"group_id":"dlfsdds"
}
ps. list is from
for (int k=0;k<allMember.size();k++){
list.add(allMember.get(k));
}
what is my mistake? and How to fix it?
thank for your help:D
JSONArrayfrom thelist, and then add that. Otherwise the list will be converted to a string when it is added to theJSONObject.