I am getting this error:
Error parsing data org.json.JSONException: Value
This is my logcat log:
11-11 22:47:28.930: D/my(25127): method equals POST is working
11-11 22:47:28.930: D/my(25127): HTTp client is working
11-11 22:47:28.930: D/my(25127): HTTp post is working
11-11 22:47:28.930: D/my(25127): url encoded
11-11 22:47:29.070: D/my(25127): HTTp response is working
11-11 22:47:29.070: D/my(25127): HTTp entity is working
11-11 22:47:29.070: D/my(25127): getcontent is working
11-11 22:47:29.070: D/my(25127): buffer reader crated
11-11 22:47:29.070: D/my(25127): string buffer object crated
11-11 22:47:29.070: D/my(25127): line appended
11-11 22:47:29.070: D/my(25127): inputstram closed
11-11 22:47:29.070: D/my(25127): string buffer to string conversion
11-11 22:47:29.070: E/JSON Parser(25127): Error parsing data org.json.JSONException: Value prepared of type java.lang.String cannot be converted to JSONObject
Error can be in server side script.
The pure JSON response is:
{"success":1,"message":"account successfully created."}
I have tested it in my browser.
I solved the question myself.
In backend PHP file, I used echo
statements, which also outputted as response. So, the json String contained a html tags and/or lines and so, it couldn't be parsed.
Remove all echo
statements or relative statements in your backend file. It will work. Thanks.
You json String contains a <br />
tag so it can't be parsed.
Try you url in a browser and check that the result is pure json.
Convert the string to json object in post execute method.
来源:https://stackoverflow.com/questions/26870860/error-parsing-data-org-json-jsonexception-value-br-of-type-java-lang-string-ca