Note that there are some explanatory texts on larger screens.

plurals
  1. POExtracting array from response string
    primarykey
    data
    text
    <p>I have a response like below from node how do I extract it to be as array in java</p> <pre><code>[ { "userName":"Steve", "date":"Tue Aug 13 18:44:23 GMT+05:30 2013", "message":"Good morning sir." } ] </code></pre> <p>Note : finally did it guys, sorry for wasting you guys time, see my last comment :)</p> <p>i'm making an http request to server written node, and in server i'm sending an array of objects [{}, {}, ...] back to java, now coming to java, i'll read the response using InputStream and constructing the result String.</p> <p>and i'm getting the string like specified above, what i want is like how to convert the string to array so that i can loop and access the objects in the array</p> <pre><code>HttpGet httpget = new HttpGet('some uri'); HttpEntity httpentity = httpclient.execute(httpget).getEntity(); private void renderResponseAndQueueResults(HttpEntity httpentity) { try { InputStream is = httpentity.getContent(); String result = convertStreamToString(is); is.close(); appendResultToMap(result); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } private String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while( (line = reader.readLine()) != null){ sb.append(line + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally{ try{ is.close(); }catch (IOException e){ e.printStackTrace(); } } return sb.toString(); } </code></pre> <p>the return of the convertStreamToString is an String like </p> <pre><code>[ { "userName":"Steve", "date":"Tue Aug 13 18:44:23 GMT+05:30 2013", "message":"Good morning sir." } ] </code></pre> <p>now how can i loop through it</p>
    singulars
    1. This table or related slice is empty.
    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.
    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