When dealing with a json string containing a property value with a double quote, I encounter issues with parsing it.
For instance, if my object is { "Name" : "Six \" Pipe" }
, attempting to parse it leads to an error message saying - Unexpected token P
.
var str = '{ "Name" : "Six \" Pipe" }';
JSON.parse(str); //error
$.parseJSON(str); //error
The string is generated in a razor view as shown below -
var str = new JavaScriptSerializer().Serialize(obj);
Subsequently, in JavaScript, I attempt to do the following
var obj = JSON.parse('@(Html.Raw(str))');
Is there a way to successfully parse such strings?