Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid JSON parse error with date
    text
    copied!<p>Having problems parsing this JSON data in my Android App :</p> <pre><code>[{"personid":20,"personName":"Ross Gallagher update3","email":"ross_gallagher@rossgallagher.co.uk","birthday":{"date":"2013-01-01 00:00:00","timezone_type":3,"timezone":"America\/Los_Angeles"},"anniversary":{"date":"1900-01-01 00:00:00","timezone_type":3,"timezone":"America\/Los_Angeles"},"Credit":2}] </code></pre> <p>The error I am getting is:</p> <pre><code>W/System.err: org.json.JSONException: Value [{"birthday":{"date":"2013-01-01 00:00:00","timezone":"America\/Los_Angeles","timezone_type":3},"anniversary":{"date":"1900-01-01 00:00:00","timezone":"America\/Los_Angeles","timezone_type":3},"email":"ross_gallagher@rossgallagher.co.uk","personName":"Ross Gallagher update8","Credit":2,"personid":20}] of type org.json.JSONArray cannot be converted to JSONObject </code></pre> <p>My JSON Parser code is:</p> <pre><code>public JSONObject getJSONFromUrl(String url) { HttpEntity httpEntity = null; JSONObject respObject = null; // Making HTTP request try { // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); httpEntity = httpResponse.getEntity(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if(httpEntity != null){ try { respObject = new JSONObject(EntityUtils.toString(httpEntity)); } catch (JSONException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } //.... } // return JSON return respObject; } </code></pre> <p>All I need is to pull out the Birthday details from this JSON object along with the name, email, credits and anniversary.</p> <p>Any advice would be appreciated!</p>
 

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