是否可以覆盖使用JSON.NET基于JSON对象的属性类型解析?基于现有的API,它看起来像我需要接受 JsonPropertyCollection
并返回键入
来创建的一种方式。
Is it possible to override the type resolution using JSON.NET based on a property of the JSON object? Based on existing APIs, it looks like I need a way of accepting a JsonPropertyCollection
and returning the Type
to be created.
注:我知道的 TypeNameHandling属性的,但增加了一个 $类型
属性。我没有在源JSON控制。
NOTE: I'm aware of the TypeNameHandling attribute, but that adds a $type
property. I do not have control over the source JSON.
推荐答案
这样看来,这种处理通过创建一个自定义的JsonConverter并将其添加到 JsonSerializerSettings.Converters
deserialisation之前。
It would appear that this is handled by creating a custom JsonConverter and adding it to JsonSerializerSettings.Converters
before deserialisation.
困惑留下了一个方便的样品上的
相关推荐
最新文章