Org.JSON.JSONexception: Value <Br of Type Java.Lang.String Cannot Be Converted to JSONobject

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

Thanks I manage to correct some of the errors 2 ';' were missing and I could see the error with Log.i("tagconvertstr", "["+result+"]");

The msg that it is showing is something like that :

[<br/ > font size = 1 table class=''xdebug-erroe' dir='ltr' ... loads of html code that wasn't in my initial code then....{"message":"Problem sending you the activation mail !"}]

So there's a problem with the json format on that message "Problem sending you the activation mail" but the user was registered OK!

So the second time i would try that code it would show me in a correct json format : "This email has already been used" ! (without any errors) but i still can't find the error in my php code : S

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

When instantiating a JSONObject you need to pass the actual string response:

ex: JSONObject obj = new JSONObject("result":[{"unique_id":"57933c641237d4.96974874","title":"23072016"},{"unique_id":"57901472464398.57585757","title":"hayley"}]");

Given that response.toString() gives you the string you should do the following:

JSONObject j = new JSONObject(response.toString());

P.S: I think you need this if you don't set the content type in your php :

<?
header('Content-Type: application/json');
$servername = "localhost";
$username = "USER";
$password = "PASS";
$dbname ="android_api";
....

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

You most likely got broken PHP code, line

echo_json_encode($result);

should rather look like that:

echo json_encode($result);


Related Topics



Leave a reply



Submit