-4

How to fix this error in my logcat...

org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject

enter image description here

Paul
  • 4,160
  • 3
  • 30
  • 56
johnpaul papa
  • 11
  • 1
  • 3

2 Answers2

2

your string which is logged in the clip is in HTML format, not JSON.

https://developer.android.com/reference/org/json/JSONObject.html

JSONObject jobj = new JSONObject();
try {
     jobj = new JSONObject(string);
} catch (JSONException e) {
     //e.printStackTrace();
}

will give you a json object if your input is in correct json format

Harsh Ganatra
  • 411
  • 3
  • 8
1
try {

    JSONObject jsonObject = new JSONObject(YOUR_STRING);
} 
catch (JSONException e) {
   e.printStackTrace();
}
K.D.U
  • 21
  • 4