SharpYaml
SharpYaml copied to clipboard
Question: Can SharpYaml handle merging?
Yaml has support for merging which allows for sort-of templating in YAML:
---
- &CENTER { x: 1, y: 2 }
- &LEFT { x: 0, y: 2 }
- &BIG { r: 10 }
- &SMALL { r: 1 }
# All the following maps are equal:
- # Explicit keys
x: 1
y: 2
r: 10
label: center/big
- # Merge one map
<< : *CENTER
r: 10
label: center/big
- # Merge multiple maps
<< : [ *CENTER, *BIG ]
label: center/big
- # Override
<< : [ *BIG, *LEFT, *SMALL ]
x: 1
label: center/big
Is this supported in SharpYaml?
I don't remember exactly, but the code is in AnchorSerializer.cs
I think that I didn't implement the full stuff system that supports forward reference, so basically, it is working only when reading a YAML document, the reference was pre-declared. Why forward reference were not implemented? Don't recall exactly, but it was tricky to integrate it without too many internal changes and/or heavier serialization hooks...
Thanks!
I'll give it a serious try then...
it is working only when reading a YAML document
Does mean it will also work when deserialiazing a document with anchors that do a back reference?
Does mean it will also work when deserialiazing a document with anchors that do a back reference?
Sorry, was not clear. It only works with this case. Forward reference will not work.