标签:
按源码中的实例 来测试
测试地址 http://localhost:55581/restApi/secure/?ApiKey=15c6b59b-fd96-43ad-99d2-7f394f992721
返回结果
{"secureContent":"here\u0027s some secure content that you can only see if you provide a correct apiKey","user":{"username":"admin"}}
而源码中是这样写的
return this.Response.AsJson(new
{
SecureContent = "here‘s some secure content that you can only see if you provide a correct apiKey",
User = userModel
});
也就是把‘s进行了转码
这是源码中的方法
public static Response AsJson<TModel>(this IResponseFormatter formatter, TModel model, HttpStatusCode statusCode = HttpStatusCode.OK)
{
var serializer = jsonSerializer ?? (jsonSerializer = formatter.Serializers.FirstOrDefault(s => s.CanSerialize("application/json")));
var r = new JsonResponse<TModel>(model, serializer);
r.StatusCode = statusCode;
return r;
}
可以据此来自己写扩展方法 使用json.net 获取其他的库来解决。
标签:
原文地址:http://www.cnblogs.com/wang2650/p/4829629.html