Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li>Provide the entire buffer you get from the network to a <a href="http://developer.android.com/reference/org/json/JSONObject.html" rel="nofollow"><code>JSONObject</code></a>.</li> <li>[<strong>Edit:</strong> Corrected thanks to @MisterSquonk] From the <code>JSONObject</code> get the value of "rates" as another <code>JSONObject</code> using <a href="http://developer.android.com/reference/org/json/JSONObject.html#getJSONObject%28java.lang.String%29" rel="nofollow"><code>getJSONObject("rates")</code></a>.</li> <li>Iterate over the keys of the "rates" object to get its values.</li> </ol> <p>Here's the code:</p> <pre><code>private class DownloadWebPageTask extends AsyncTask&lt;String, Void, ArrayList&lt;String&gt;&gt; { @Override protected ArrayList&lt;String&gt; doInBackground(String... urls) { ArrayList&lt;String&gt; response = new ArrayList&lt;String&gt;(); for (String url : urls) { DefaultHttpClient client = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse execute = client.execute(httpGet); InputStream content = execute.getEntity().getContent(); InputStreamReader isr = new InputStreamReader(content); StringBuilder sb = new StringBuilder(); char[] buffer = new char[1024]; while (isr.read(buffer) != -1) { sb.append(buffer); } JSONObject jobj = new JSONObject(sb.toString()); JSONObject ratesObj = jobj.getJSONObject("rates"); Iterator&lt;String&gt; keys = ratesObj.keys(); while (keys.hasNext()) { response.add(ratesObj.getString(keys.next())); } } catch (Exception e) { e.printStackTrace(); } } return response; } } </code></pre>
 

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