I have a string with double quotes in ms-sql server :

enter image description here

I am passing it to view like so:

var json = '@Html.Raw(JsonConvert.SerializeObject(Model))';
var viewModelData = $.parseJSON(json);

In runtime it renders like so:

var json = '{"Description":"\"I am text in double quotes\""}';

But then $.parseJSON() throws an exception:

enter image description here

有帮助吗?

解决方案

I was doing a lot of unnecessary stuff here.
All I need is:

var viewModelData = @Html.Raw(JsonConvert.SerializeObject(Model));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top