2

I have an application where i want to fetch data from local server. like

{
    "restarutant":{
    "name":"Hotel Raja",
    "photo":"http:\/\/i.imgur.com\/Mzt4u.jpg",
    "address":"93, 2ndc ross, GDP etx.",
    "area":"Vylaikaval",
    "city":"Bangalore",
    "location":["13.005621","77.577531"],
    "phone":["9986377561","08023467969"],
    "rating":"4",
    "cuisines":["Chinese","Korean"],
    "attributes":["smoking","parking","delivery"]
    }
}

means array within an array please anybody tell me how i retrieve each data from this. Thank you

2 Answers 2

2

Try this code:

        String str_json = "your json string from query";

    try {
        JSONObject topobj = new JSONObject(str_json);
        JSONObject innerobj = topobj.getJSONObject("restarutant");

        String name = innerobj.getString("name");
        String photo = innerobj.getString("photo");
        JSONArray cuisines = innerobj.getJSONArray("cuisines");
        //etc etc...

    } catch (JSONException e) {
        e.printStackTrace();
    }
Sign up to request clarification or add additional context in comments.

Comments

2

Check out the manual example using the Tokenizer or use your own implementation.

Also read this post: Sending and Parsing JSON Objects answers your question.

1 Comment

ya but i want to know how to retrieve in my abdroid activity page. please give me that answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.