JSON.Net: deserializing polymorphic types without specifying the assembly

前端 未结 1 982
南笙
南笙 2020-12-06 13:12

I see that using JSON.Net, I can decode polymorphic objects if a $type attribute specifies the specific type of the JSON object. In all the examples I\'ve seen,

相关标签:
1条回答
  • 2020-12-06 13:50

    Create a derived SerializationBinder in which override BindToName and Set out string assemblyName to null (Edit: or your default assembly name) and out string typeName to your striped type name

    Set the binder to the JsonSerializerSettings.Binder before serialisation.

    Let me know if this is not working

    0 讨论(0)
提交回复
热议问题