tags:

views:

63

answers:

2

hi, i want to convert from json object

"{"CNo":80,"CName":"ganesh","CMail":"[email protected]","CMailType":"home","CPhNo":9878987776,"CPhNoType":"home","ClientNo":1}"

to

"{\"CNo\":80,\"CName\":\"ganesh\",\"CMail\":\"[email protected]\",\"CMailType\":\"home\",\"CPhNo\":9878987776,\"CPhNoType\":\"home\",\"ClientNo\":1}" ??

A: 

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.

Kaustubh P
do we have anything like javascriptserializer as we use in .net?
ganesh
hi kaustubh.. thanx.. i need to be in that '\' format for post operation..
ganesh
im sorry, im not familiar with .net. you can define a "\" and append it/insert it where you require.
Kaustubh P
ok.... thanks :)
ganesh
A: 

Try use toString() on your JSON object

Sergey Glotov
ya i checked.. its the same object which is returning.. to the stringentity.. !! im assigning the json.tostring() to a stringentity variable so that i can use this to post to a .net rest client
ganesh