Okay, so I am brand spanking new to C#, got assigned something and now find myself working in c#. I am using this jrock library to create JSON objects for talking back to this servlet I have (that is written in java). THe JSON object I can build up and then do a call on the object:
string ret = myJsonObj.ToString();
but ret has a string that has extra characters that makes my socket code honk..namley a \" how do I supress these I need a string like:
{"sessionKey":"The key #4241242132","method":"init"}
what it is returning form ToString(); though:
{\"sessionKey\":\"The Key #4241242132\",\"method\":\"init\"}
how do I stop those slashes? thanks
Shane
Loading
SimonPosted Apr 6, 2007, 5:27 PM
I don't know that particular library about JSON, but in c#, as long as you'll want to keep " inside a string, it will necessarily be represented as \" inside that string object (since the string delimiter is "). This extra \ will be removed if you serialize your string to a file or any other storage. It's even surprising that the servlet you're using doesn't remove those backslashes automatically...which could also be an option if you have access to the servlet's code.
Hope this helps!
Simon