Bit new to JSON so please excuse the simpleton question, but according to the list of special characters found here and here, single quote (‘) characters are meant to be escaped. The specification also treats solidus (/) as escapable character. To illustrate I’m using the documentation example (slightly modified).
input:
Product product = new Product();
product.Name = "O'Grady's Apples";
product.Expiry = new DateTime(2008, 12, 28);
product.Price = 3.99M;
product.Sizes = new string[] { "Small", "Medium", "Large", "X/Large" };
output = JsonConvert.SerializeObject(product, Formatting.Indented);
output:
{
"Name": "O'Grady's Apples",
"Expiry": "\/Date(1230422400000+0000)\/",
"Price": 3.99,
"Sizes": ["Small","Medium","Large", "X/Large"]
}
What I would expect to see is
{
"Name": "O\'Grady\'s Apples",...
"Sizes": ["Small","Medium","Large", "X\/Large"]
}
Is this intended? Or am I misinterpreting the specifications?
While everything can be escaped inside a string, only a very limited set needs to be escaped:
So only
",\and the unprintable control characters must be escaped.