1

Closed

forward slash is not escaped in ToString() method

description

Closed Mar 6, 2012 at 11:53 PM by JamesNK
.

comments

KubuS wrote Mar 2, 2012 at 2:06 PM

sorry for not providing an example - didn't know ctrl+s is a hot key for posting ;)

var jObj = new JObject(
new JProperty("bad_slash", "slash/not escaped")
);
Console.WriteLine(jObj.ToString());

output:
{
"bad_slash": "slash/not escaped"
}
notice the slash is not escaped.

carlosfigueira wrote Mar 2, 2012 at 5:19 PM

The forward slash doesn't have to be escaped. It can be escaped, just like the 'a' character can be written out as '\u0061'. The only characters which need escaping are the backslash, double quotes and control characters (those under \u0020) - see the RFC at http://www.ietf.org/rfc/rfc4627.txt for the JSON string grammar.

KubuS wrote Mar 2, 2012 at 6:04 PM

@carlosfigueira I've read the RFC and you're right. I guess the issue can be closed then.