6

I want the name, email and image for each TAG.I have to show in List element.

{
   "response":[
      {
         "name":"Brajendra Mishra",
         "email":"[email protected]",
         "address":"Information Service\r\nParliament of Canada\r\nOttawa, Ontario K1A 0A9",
         "aboutus":"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. ",
         "image":"http:\/\/74.52.209.213\/lab\/event\/img\/attachments\/photos\/small\/4f2a5a71-acc0-4319-b1ca-14774a34d1d5.jpg"
      },
      {
         "name":"Toney Grey",
         "email":"[email protected]",
         "address":"Information Service\r\nParliament of Canada\r\nOttawa, Ontario K1A 0A9",
         "aboutus":"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. ",
         "image":"http:\/\/74.52.209.213\/lab\/event\/img\/attachments\/photos\/small\/4f1d4283-5204-4f16-90d6-69924a34d1d5.jpg"
      }
   ],
   "count":2
}

I tried a lot but not able to do.

Just let me know the Loops, how to reach the values for each name, email, image etc, how to hold.

2
  • 1
    I am sorry man, we need more info. What is the first piece of JSON, what is the second one? Also, are you not using the JSONObject? Are you using ArrayLists? Commented Mar 2, 2012 at 7:35
  • Thanks for ur quick response. Give me some time, m giving u more info. Commented Mar 2, 2012 at 7:57

2 Answers 2

9

I generate a solution for ur ussue.

JSONArray jObject = new JSONArray(jsoninputstring);
        for (int i = 0; i < jObject.length(); i++,start++) {
             JSONObject menuObject = jObject.getJSONObject(i);

             String name= menuObject.getString("name");
             String email= menuObject.getString("email");
             String image= menuObject.getString("image");
        }
Sign up to request clarification or add additional context in comments.

1 Comment

What's the "start++" jazz?
5

try like this

where jObj is response which you get from server.

try { 
        JSONObject get_string = new JSONObject(jObj.toString()); 

        jsonProduct_jsonarray = new JSONArray();

        jsonProduct_jsonarray = get_string .getJSONArray("response");

        // Receive the JSON object from server
        for (int i = 0; i < jsonProduct_jsonarray.length(); i++) {

            System.out.println("GOT JSON VALUE ");
            JSONObject c = jsonProduct_jsonarray.getJSONObject(i);

            String name= c.getString("name");
            String  email= c.getString("email");
            String  address= c.getString("address");
            String  aboutus= c.getString("aboutus");
            String   image= c.getString("image"); 
        }

goto this working example, this might help you out

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.