Bishal
Bishal

Reputation: 29

I want to generate NAMEVALUEPAIR for this type of json structure

{ "name": "ABC", "title": "bcd", "looper": { "l1": "ghi", "l2": "jkl" } }

How can we achieve name value Pair using such a format.

Upvotes: 0

Views: 61

Answers (2)

Rathan Kumar
Rathan Kumar

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

SANJAY GUPTA
SANJAY GUPTA

Reputation: 1604

For doing so you have to make Json Object to send data.It work similary to Name Pair value.

Upvotes: 0

Related Questions