如何在 Android 中创建嵌套的 JSON。 JSON 数据应如下所示:
JSON
Customername = Roshan
Customercode = 100
Customercity = Ernakulam
Customerstate = Kerala
Customercountry = India
Customersales
Productname = Biscuit
Productcode = 123
Producttype = Food
Customersales
Productname = Shoes
Productcode = 234
Producttype = Dress
注意:我能够在没有嵌套的情况下创建 JSON,但我无法创建嵌套的 JSON 数据。我们如何做到这一点?
最佳答案
您将使用 JSONObject。
创建一个 JSONObject:
JSONObject json = new JSONObject();
添加元素:
json.accumulate(key,value);
获取 JSON:
json.toString;
关于android - 如何在 Android 中创建 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24261049/