How to convert json object to string in android ..?

I want to convert from JSONObject

{"CNo":80,"CName":"ganesh","CMail":" ganesh@ganesh.com ","CMailType":"home","CPhNo":9878987776,"CPhNoType":"home","ClientNo":1}

to

{\"CNo\":80,\"CName\":\"ganesh\",\"CMail\":\" ganesh@ganesh.com \",\"CMailType\":\"home\",\"CPhNo\":9878987776,\"CPhNoType\":\"home\",\"ClientNo\":1}

+9
source share
2 answers

Hope this helps. Just found out yesterday :)

 JSONObject foo = yourJSONOject; String uid = foo.get("CNo").isString().toString(); String type = foo.get("CName").isString().toString(); . . //for each Key field. 

I'm not sure why you put the escape strings in the string, but you can call append() and get the OP as you want.

+5
source

Try using toString() for your JSON object

+10
source

All Articles