YAML representation can be expressed in serial API by doing two things
- Imposing an ordering on mapping keys and
- Mentioning aliasing nodes for the subsequent occurrences of the anchor nodes. The result of the above process is known as Serialization tree.
The two important concepts of serialization tree are keys order and anchors and aliases.
Keys order – From the representation model mapping keys are not ordered. To serialize mappings you should impose an ordering on maps. Ordering mappings can be treated as sequence of mappings. Mapping is a key: value pair.
Anchors and Aliases – A node can appear more than one time in a collection. The first occurrence is termed as an anchor and subsequent occurrences are considered as aliases which will refer back to the anchor. when a representation graph is constructed from serialization events alias will refer to most recent node having specified anchor. Anchors need not to be unique in this context.