Deserialization of self-referencing properties does not work

前端 未结 3 432
日久生厌
日久生厌 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条回答
  •  隐瞒了意图╮
    2020-11-30 15:38

    Using references doesn't work with objects that only have constructors with parameters.

    Json.NET has to deserialize all the child values before it creates the parent, it needs those values to pass to the constructor, so there is no valid parent reference to assign to the child.

提交回复
热议问题