3

If I have a POCO defined in C#, can I control how the properties of that POCO are represented in YAML?

For example:

class A
{
      string Name{get;set;}
}   

I would like it to be serialized as below (lower case, essentially):

a:
 name: value

In json.net I can decorate the POCO using attributes that determine how that object should be serialized. Is there an equivalent in YamlDotNet?

iagomartinez
  • 172
  • 10

2 Answers2

3

You can choose the naming convention that will be used by the serializer and deserialiser. You can also decorate your members with [YamlAlias("name")] to alter the name of a particular member.

Antoine Aubry
  • 12,203
  • 10
  • 45
  • 74
0

This can also be achieved using YamlMember (e.g. [YamlMember(Alias = "name")]).

YamlMember can also be used to control the order of items as they're serialised.

Jonathan Williams
  • 2,015
  • 1
  • 19
  • 23