I was doing a lot of unnecessary stuff here.
All I need is:
var viewModelData = @Html.Raw(JsonConvert.SerializeObject(Model));
题
I have a string with double quotes in ms-sql server :
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:
解决方案
I was doing a lot of unnecessary stuff here.
All I need is:
var viewModelData = @Html.Raw(JsonConvert.SerializeObject(Model));