Serializing strings containing apostrophes with JSON.Net

后端 未结 4 1128
我在风中等你
我在风中等你 2020-12-03 10:47

I am using JSON.Net as my serializer for a large MVC 3 web application in c# and the Razor view engine. For the initial page load in one view, there is a large amount of JSO

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 11:07

    Use System.Web.HttpUtility.HtmlEncode

    HttpUtility.HtmlEncode(JsonConvert.SerializeObject(myObject))
    

提交回复
热议问题