0

I have a YAML document as:

name: foo
description: bar

and another YAML document as:

name: foo1
desc: bar1

I am using YamlDotNet YamlMember 'Alias' property to define the attribute name. But it lets me define only one alias. I want "description" and "desc" to deserialize to a single variable. Both cannot be present in the YAML file at the same time. Is there any way I can achieve that?

Anthon
  • 69,918
  • 32
  • 186
  • 246

1 Answers1

0

That is not possible just using YAML. Anchors (and their use as aliases) do not carry over from YAML document to YAML document within one file, so certainly not from YAML documents in different files.

You can try to do some postprocessing yourself after the YAML is loaded, but you probably cannot use aliases during that postprocessing as "anchor names are a serialization detail and are discarded once composing is completed", so you would have to go for some unique string template or for special alias objects that you easily find in the object trees loaded from YAML.

Anthon
  • 69,918
  • 32
  • 186
  • 246