Do not want to escape quotations

Apr 21, 2009 at 6:49 PM
Using either JsonConvert.SerializeObject, or creating my own JsonSerializer and using JsonTextWriter, all double quotation character (") are escaped (\"). I would like to not have them escaped. Is there an attribute or property or simple way to do this with Json.NET?

Thanks,
 Bob
Coordinator
Apr 22, 2009 at 12:10 AM
Edited Apr 22, 2009 at 12:10 AM
If they aren't escaped then the JSON will be invalid since double quotes are used to start and end strings.

You could set the QuoteChar property on JsonTextWriter to be single quote in which case single quote characters will be escaped instead.
Aug 14, 2009 at 10:51 AM

The 'standard' asp.net mvc JSONRESULT does not seem to add escapes and jquery is happy to consume it. How do you set the QuoteChar property proerty. Thanks.

Christian

Coordinator
Aug 15, 2009 at 1:55 AM

Are you returning the Json.NET string result in a JsonResult? If so then JsonResult is encoding it as one big string...