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

I hope this helps. Just learnt it yesterday :)

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

I am not sure why you have put the escapes in the string, but you can call append() and get the OP as you want it.


Below code will convert the given JsonObject to string.

Gson gson = new Gson();
String bodyInStringFormat = gson.toJson(passYourJsonObjectHere);

Try to use toString() on your JSON object

Tags:

Json

Android