Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON Parsing works on Android 4.0 but not on Android < 4.0
    text
    copied!<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/7254962/json-parsing-problem">JSON parsing problem</a> </p> </blockquote> <p>I am parsing a JSON file (Which is valid). It works on Android 4.0 - 4.0.4 but not on older Android versions. This is a part of my Manifest:</p> <pre><code>&lt;uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14" /&gt; </code></pre> <p>And this is my parsing code:</p> <pre><code>public JSONObject getJSONFromUrl(String url) { try { DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "UTF-8"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } return jObj; } </code></pre> <p>And on the older devices I get the following error message (But as I said not on new Android devices): </p> <blockquote> <p>org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject</p> </blockquote> <p>I have absolutely no idea why it does work on Android 4 but not on older devices.</p> <p>Find the Json from <a href="http://pastebin.com/Jp6Z2wmX" rel="nofollow noreferrer">here</a></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