The moose likes Android and the fly likes java.lang .String cannot be converted into JSONObject Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "java.lang .String cannot be converted into JSONObject" Watch "java.lang .String cannot be converted into JSONObject" New topic

java.lang .String cannot be converted into JSONObject

Kruthika Srinivasan

Joined: Jan 22, 2014
Posts: 3
Hi i used this tutorial to insert data in my online server .it works fine but i am unable to get json response.
It is showing" Error parsing data org.json.JSONException: Value success of type java.lang.String cannot be converted to JSONObject"
I am completely new to PHP and Json. please help

my insert.php is

and my CustomHttpClient.java

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41064
Print out the value of the JSON you're receiving so you know what you're dealing with.

I bet the problem is lines 5 to 12 of your PHP code - you're returning something that is not JSON.

And you shouldn't be doing a DB query if the code can't even connect to the DB.

Ping & DNS - my free Android networking tools app
jQuery in Action, 2nd edition
subject: java.lang .String cannot be converted into JSONObject
Similar Threads
org.json.JSONException: No value for user
client server connectivity problem
Sending a jason object via Post
Unrecognized Property in fetching data from JSONObject in Jersey web service
Unable to fetch correct json string