3

Using the following example is it possible to use the AddChild Setter method in Json.Net during Deserialization to populate the list of children?

public class Foo
{
    private IList<Foo> _children;
    private Foo _parent;

    public Foo()
    {
         _children = new List<Foo>();
    }

    public string Name { get; set; }
    public IEnumerable<Foo> Children
    {
         get { return _children.AsEnumerable() }
    }

    public void AddChild(Foo child)
    {
         child._parent = this;
         _children.Add(child);
    }
}

1 Answer 1

3

You can add a custom type converter by creating a concrete implementation of the JsonConverter class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.