Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject [closed]

一笑奈何 提交于 2019-12-18 03:00:20

问题


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.


回答1:


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.




回答2:


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.




回答3:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!