2
多個值,我就JSON初學者在Java中http://json.org/java/一個JSON關鍵
如何創建這樣一個JSON對象?
{
"RECORD": {
"customer_name": "ABC",
"customer_type": "music"
}
}
多個值,我就JSON初學者在Java中http://json.org/java/一個JSON關鍵
如何創建這樣一個JSON對象?
{
"RECORD": {
"customer_name": "ABC",
"customer_type": "music"
}
}
嘗試這樣的:
JSONObject jsonObject = new JSONObject();
jsonObject.put("customer_name", "ABC");
jsonObject.put("customer_type", "music");
JSONObject jsonObject_rec = new JSONObject();
jsonObject_rec.put("RECORD", jsonObject);
System.out.println(jsonObject_rec);
你必須做出 「RECORD」 一個JSONObject的。這是一個例子:
JSONObject json = new JSONObject();
// Add a JSON Object
JSONObject Record = new JSONObject();
Record.put("customer_name", "ABC");
Record.put("customer_type", "music");
json.put("RECORD", Record);
// P toString()
System.out.println("JSON: " + json.toString());