如何在模型属性中返回json字符串而不对Web API进行转义?

时间:2017-06-09 16:59:13

标签: c# json asp.net-web-api

我有一个API,我需要返回一个带有属性的模型,该属性本身带有一个JSON字符串。内部的JSON字符串在客户端收到时会被转义。

实际:{\" ShowFilter \":true,\" FilterOptions \":[\" Week \",\"月\",\"年\"] \" DefaultFilter \":\"周\",\" ShowLegend \":真,\" ShowVerticalAxis \":真,\" VerticalAxisInterval \":30,\" VerticalAxisIntervalType \":\& #34;整数\"}

预期:{" ShowFilter":true," FilterOptions":[" Week"," Month"," Year& #34]," DefaultFilter":"周"" ShowLegend":真," ShowVerticalAxis":真," VerticalAxisInterval& #34;:30," VerticalAxisIntervalType":"整数"}

如何在不忽略序列化的情况下避免属性转义?

1 个答案:

答案 0 :(得分:0)

我假设您在Visual Studio中查看它。启动API并在其运行时,使用Chrome之类的浏览器(或Postman之类的工具)来调用API。这将显示调用对象正在传递的内容。