Note that there are some explanatory texts on larger screens.

plurals
  1. POJSONException: Value of type java.lang.String cannot be converted to JSONObject
    text
    copied!<p>I have a JSON file with 2 JSON-Arrays in it: One Array for routes and one Array for sights.</p> <p>A route should consist of several sights where the user gets navigated to. Unfortunately I am getting the error:</p> <p>JSONException: Value of type java.lang.String cannot be converted to JSONObject</p> <p>Here are my variables and the code that parses the JSON-File:</p> <pre><code>private InputStream is = null; private String json = ""; private JSONObject jObj = null; try { BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); // hier habe ich das JSON-File als String json = sb.toString(); Log.i("JSON Parser", json); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } // return JSON String return jObj; } </code></pre> <p>Log.i("JSON Parser", json); shows me that at the beginning of the generated string there is a strange sign: <img src="https://i.stack.imgur.com/uOiX8.png" alt="enter image description here"></p> <p>but the error happens here:</p> <pre><code>try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } </code></pre> <blockquote> <p>04-22 14:01:05.043: E/JSON Parser(5868): Error parsing data org.json.JSONException: Value //STRANGE SIGN HERE // of type java.lang.String cannot be converted to JSONObject</p> </blockquote> <p>anybody has a clue on how to get rid of these signs in order to create the JSONObject?</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