在这个链接上,在备注部分提到了" TypeNameHandling".在什么情况下,如果使用序列化/反序列化来自外部源的JSON会有害SerializationBinder?一个工作的例子将不胜感激.
我的web api中有以下方法
public void Put(string id, [FromBody]IContent value) {
//Do stuff
}
Run Code Online (Sandbox Code Playgroud)
我正在使用骨干js使用fiddler将以下JSON发送到服务器,值为null:
{
"id": "articles/1",
"heading": "Bar",
"$type": "BrickPile.Samples.Models.Article, BrickPile.Samples"
}
Run Code Online (Sandbox Code Playgroud)
但是如果我在JSON对象中首先添加$ type属性,反序列化工作正常,请参阅:
{
"$type": "BrickPile.Samples.Models.Article, BrickPile.Samples",
"id": "articles/1",
"heading": "Bar"
}
Run Code Online (Sandbox Code Playgroud)
是否可以配置newtonsoft以检查对象中的$ type属性而不是第一个属性,还是可以配置主干,以便它始终$type首先在JSON对象中添加属性?
serialization json.net backbone.js asp.net-mvc-4 asp.net-web-api