Note that there are some explanatory texts on larger screens.

plurals
  1. POorg.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
    primarykey
    data
    text
    <p>Hi i got a problem with Android JSON Parser in 2.3, all is ok in 4.0>.</p> <p>I look other topic they are talking about encoding (server) or other stuff server side, but i tried to put "test" in all my JSON field an the problem still persist.</p> <p>Here is my code : </p> <pre><code>URL url = new URL(c.getString(R.string.url_ws) + url_ws); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestMethod("POST"); OutputStreamWriter request = new OutputStreamWriter(connection.getOutputStream()); request.write("&amp;test=test"); request.flush(); request.close(); String line; InputStreamReader isr = new InputStreamReader(connection.getInputStream()); BufferedReader reader = new BufferedReader(isr); StringBuilder sb = new StringBuilder(); while ((line = reader.readLine()) != null){ sb.append(line + "\n"); } String json = sb.toString().trim(); try { JSONObject obj = new JSONObject(json); } catch (JSONException e) { e.printStackTrace(); Log.d(Tools.TAG+"/debug JSONException", e.toString()); return null; } </code></pre> <p>Here is my exception </p> <pre><code>debug JSONException(4184): org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject </code></pre> <p>i saw double space between "Value" and "of" so i guess the problem is a empty string but i dont get it.</p> <p>thanks.</p> <p><strong>EDIT</strong></p> <p>it was a encode mistake in my JSON,</p> <pre><code>char a = json.substring(0, 1).charAt(0); int ascii = (int)a; Tools.myLog("&gt;"+ascii+"&lt;"); </code></pre> <p>i found 65279 char</p> <h1>SOLUTION</h1> <p><a href="https://stackoverflow.com/questions/9691771/why-is-65279-appearing-in-my-html">Why is &amp;#65279; appearing in my HTML?</a></p> <p>encoding UTF-8 without BOM.</p>
    singulars
    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