我的代码是:
JSONObject jChild=new JSONObject();
JSONObject jParent=new JSONObject();
for (Product p : boxAdapter.getBox()) {
if (p.checked){
try {
jChild.put("uid", p.uid);
list.add(String.valueOf(jChild));
//list.add(String.valueOf(jParent));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
jParent.put("users", list);
// Toast.makeText(this, ""+jParent, Toast.LENGTH_LONG).show();
Log.v("TakeAttendance","JSONpARENT "+String.valueOf(jParent));
输出 :
{"users":"[{\"uid\":\"4\"}, {\"uid\":\"5\"}, {\"uid\":\"6\"}]"}
我真正需要的:
{users: [
{
name: "acx",
uid: "2"
},
{
name: "test",
uid: "6"
},
{
name: "ccc",
uid: "11"
}
]
}