Reputation: 29
{ "name": "ABC", "title": "bcd", "looper": { "l1": "ghi", "l2": "jkl" } }
How can we achieve name value Pair using such a format.
Upvotes: 0
Views: 61
Reputation: 2577
try like following method:
public JSONObject writeJSON() {
JSONObject object = new JSONObject();
try {
object.put("name", "ABC");
object.put("title", "bcd");
JSONObject innerObject = new JSONObject();
innerObject.put("l1", "ghi");
innerObject.put("l2", "jkl");
object.put("looper", innerObject);
} catch (JSONException e) {
e.printStackTrace();
}
return object;
}
Upvotes: 1
Reputation: 1604
For doing so you have to make Json Object to send data.It work similary to Name Pair value.
Upvotes: 0