4 ms·
I would imagine this feature is primarily useful if you want to serialize a whole bunch of objects that all reference each other, but it makes me feel a bit ick
by OskarS 10y ago
I would imagine this feature is primarily useful if you want to serialize a whole bunch of objects that all reference each other, but it makes me feel a bit icky. It feels like it breaks an intuitive assumption you have about hierarchical formats, which is that there should be no cycles.
Maybe that's just my personal bias, but I feel like the relative simplicity of JSON is a strong feature in its favor. As a developer, I have very clear understanding of the data I'm reading, and with that I can more easily make safer and more stable code.
- junke 10y agoYet, a lot of hierarchical structures I see are full of "ref" and "id" attributes, which effectively encode cyclic graphs.
- OskarS 10y agoThat's certainly true, but at least that's not going to cause an infinite loop while wandering down the structure, it's just gonna end at a leaf "ref" or "id".
- junke 10y agoIn my view this is more a question of simple interface vs. simple implementation. Having cross-references at the language level gives a uniform and simplified interface at the cost of more having to develop careful tools. Not saying refs/id are bad, but at least with a uniform syntax and language support, you don't have to reimplement custom cross-reference resolvers.
- twelvechairs 10y agoYou are right for most use cases - which is why json is so popular. Sometimes however there is very good reason to have non-hierarchical data - and YAML fits this use case.