Deserialization of self-referencing properties does not work

前端 未结 3 440
日久生厌
日久生厌 2020-11-30 15:00

I have this object with a Parent property that reference another object of the same type:

[JsonObject(IsReference = true)]
class Group
{
    public strin         


        
3条回答
  •  猫巷女王i
    2020-11-30 15:58

    Another way, i found, by being very stubborn is creating a two phase deserialization,
    as i describe in the following Deserializing Circular References by Two-Phase deserialization

    in general, i create two IContractResolvers, One is used to deserialize only the properties of the Constructor (in case it has parameters).

    and in the second phase, I populate the object using regular ContractResolver.

提交回复
热议问题