android - json string cannot be converted to JSONObject -



android - json string cannot be converted to JSONObject -

i trying parse json string in android application getting below exception. please help

exception:

org.json.jsonexception: value { "datetime": "20 06 2014", "response": null, "hoursleft": 0, "token": null, "error": null, "istrialexpired": false }

of type java.lang.string cannot converted jsonobject

code:

jsonobject jsonobject = new jsonobject(s); // exception in line ((edittext) findviewbyid(r.id.edittextsearch)).settext(jsonobject.getstring("datetime"));

thanks guys help :)

but have solved above issue finally.

the problem format of string \" trying homecoming server.

invalid string

"{\"response\":\"6\/24\/2014 5:33:35 pm\",\"hoursleft\":0,\"token\":\"\",\"error\":\"\",\"istrialexpired\":false}"

valid string

{"datetime":"24\/06\/2014","error":"","istrialexpired":false,"response":"","hoursleft":0,"token":""}

on server side manually converting object json , returning , causing issue. used responseformat = webmessageformat.json in wcf operation contract , solved issue.

android json parsing

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -