0

I'm using YamlDotNet.

public class Parent
{
  public int Foo { get; set; }
  public bool Bar { get; set; }
}

public class Child
{
  public Parent Parent { get; set; }
  public string Baz { get; set; }
  public int Qux { get; set; }                // serialise this
  public string Spam { get; set; }
  public bool Ham { get; set; }               // serialise this
  public double Eggs { get; set; }            // serialise this
}

If I serialise Child, it will include its entire object graph - all public properties, including Parent.

How do I serialise specific properties only? For example: Qux, Ham and Eggs, only.

(I don't want to specify which properties to "exclude", but rather those to "include".)

lonix
  • 14,255
  • 23
  • 85
  • 176

0 Answers0