Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to parse this JSON response with different objects?
    primarykey
    data
    text
    <p>I have tryed a lot but anable to parse this json . i need all abjects( book, and camera)values in array. can anyone help me? How to make array of CaremaOjects Values and bookObject value.</p> <pre><code> [ { "camera":{ "picture":"http:\/\/img7.flixcart.com\/image\-imacyb5emj5yztet.jpeg", "model":"Lumix DMC-FP3 Point &amp; Shoot", "make":"Panasonic", "price":5830 } }, { "camera":{ "picture":"http:\/\/sp.sony-europe.com\/da.jpeg", "model":"Digital Still Camera - H Series - DSC-HX200V", "make":"Sony", "price":510 } }, { "book":{ "description":"What is self, and how can a", "authors":"Douglas R Hofstadter", "price":650, "id":40724766, "title":"G\u00f6del, Escher, Bach: an Eternal Golden Braid" } }, { "camera":{ "picture":"http:\/\/www.usa.canon.com\/60d_586x186.gif", "model":"Digital SLR Camera EOS 60D", "make":"Canon", "price":999 } }, { "book":{ "description":"Tgdfgf fgfg ", "authors":"Harold Abelson and Gerald Jay Sussman with Julie Sussman", "price":469, "id":51087, "title":"Structure and Interpretation of Computer Programs" } }, ] </code></pre> <p>the code i am using is public void getDetalFromServer() { // TODO Auto-generated method stub</p> <pre><code> String URL="xyz.php"; HttpClient client= new DefaultHttpClient(); HttpPost post=new HttpPost(URL); try { HttpResponse response =client.execute(post); HttpEntity getResEntity=response.getEntity(); String result=""; if(getResEntity!=null){ result=EntityUtils.toString(getResEntity); System.out.println("result from server: "+result); bookDescription=new ArrayList&lt;String&gt;(); bookAuthors=new ArrayList&lt;String&gt;(); bookPrice=new ArrayList&lt;String&gt;(); bookID=new ArrayList&lt;String&gt;(); bookTitle=new ArrayList&lt;String&gt;(); responseArray=new JSONArray(result); for(int i=0;i&lt;responseArray.length();i++){ JSONObject bookObject=(JSONObject) responseArray.getJSONObject(i); bookDescription.add(bookObject.get("description").toString()); bookAuthors.add(bookObject.get("authors").toString()); bookPrice.add(bookObject.get("price").toString()); </code></pre> <p>bookID.add(bookObject.get("id").toString()); bookTitle.add(bookObject.get("title").toString());</p> <pre><code> } } } catch (Exception e) { // TODO: handle exception } } </code></pre> <p>Using this code i am able to just get the first object of the Response.(rite now i am just trying to parse Music object from the response that why i didnt handled ) thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload