1 回答
TA贡献1809条经验 获得超8个赞
您可以尝试以下方式
try {
JSONObject obj=new JSONObject();
obj.put("id", 58);
JSONObject contact=new JSONObject();
contact.put("id", "smome value");
contact.put("first_line", "smome value");
contact.put("locality", "smome value");
JSONObject address=new JSONObject();
address.put("primary_number", "primary");
address.put("secondary_number", "secondary");
obj.put("address", address);
obj.put("contact", contact);
}catch (Exception e) {
e.printStackTrace();
}
现在输出如下所示
{
"id": 58,
"address": {
"primary_number": "primary",
"secondary_number": "secondary"
},
"contact": {
"first_line": "smome value",
"locality": "smome value",
"id": "smome value"
}
}
添加回答
举报