Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

YAML is (or at least, is declared by its maintainers to be) a superset of JSON, making any JSON document also a valid YAML document.

So surely if YAML is streamable, JSON must be too?

Or are the YAML maintainers incorrect?



> YAML is (or at least, is declared by its maintainers to be) a superset of JSON, making any JSON document also a valid YAML document. > So surely if YAML is streamable, JSON must be too?

Given YAML is not a subset, but a superset of JSON, as you correctly noted, I'm not sure how you reached that conclusion.

> Or are the YAML maintainers incorrect?

I think you should check this page before making snarky comments: https://en.wikipedia.org/wiki/Superset

See also the comment below: https://news.ycombinator.com/item?id=49476489

Offtopic note: I wanted to dig the wiki superset link up the lazy way, so searched for superset, and all I got was endless list of marketing trash links. Even on DDG. RIP, we are on the Dead Internet.


He misspelled subset/superset, but the idea with streaming is right.

Given: - YAML support streaming - any JSON is valid YAML

Conclusion - any JSON is streaming


Nope?

The "streamed JSON" needs --- line sparators, which is not a JSON spec feature, thus that data stream is valid YAML from that point, bot not a valid JSON stream.

NDJSON is a different beast.


I think you should check this page before making snarky comments: https://en.wikipedia.org/wiki/Inference

See Examples section.


> snarky comments

How was my comment snarky? The YAML maintainers may have intended YAML to be a superset of JSON, but failed by not incorporating some obscure feature of it that bore on whether it was streamable or not.


Yaml streams are just yaml docs separated by "---" withing a single file.

The json spec just doesnt do anything like that but jsonl does.


I wrote a C++ library at work that, among other things, serializes/deserializes to JSON, CBOR and BSON. I don't get that point.

The first two formats I've implemented as fully streaming, the serializers emit into an output iterator one character/byte at a time and the deserializers only need to hold one value at a time (mostly for strings, and not even for CBOR's byte arrays, which are streamed). BSON requires full document instantiation because of byte offsets and is genuinely anti-streaming in its design.

I happen to have implemented a serializer for YAML, fully streaming, mostly as a compact-ish human-readable debug data representation. I can scarcely think of fates worse than having to write a spec-compliant YAML parser.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: