考虑以下代码:
// Dictionary created.
Dictionary<string, string> objDic = new Dictionary<string, string>();
string test = "<>";
objDic.Add("html", test);
var Json = new JavaScriptSerializer();
string response = Json.Serialize(return_obj);
输出回复:
[{"html":"\u003c\u003e"}]
预期回应:
[{"html":"<>"}]
如何获得预期的响应?
答案 0 :(得分:2)
然后您可以使用Json.NET:
var str = JsonConvert.SerializeObject(new {html="<>"}) //returns {"html":"<>"}