While the following JSON is true, it does not stay the same when the string is in JavaScript, as it will be undone first:
'[{"Value":2,"Fullname":"Value \" with double quote"}]'
JavaScript will disable this first to become:
'[{"Value":2,"Fullname":"Value " with double quote"}]'
When JSON arrives, it clearly sees an unexpected character, since the quote is now looking for the end of the line. What you need to do is double quote ( \\" works), anyway, whether you want to do this at the end of JS or .NET is probably completely up to you.
However, there really is no need to parse this with JSON at all, and you can just use it as an object literal like this:
var data = @Html.Raw(ViewBag.Data);
which translates to:
var data = [{"Value":2,"Fullname":"Value \" with double quote"}];
.. which is absolutely true.
source share