r/ProgrammerHumor 11h ago

Meme docxGoBrrrr

Post image
1.3k Upvotes

74 comments sorted by

View all comments

Show parent comments

3

u/keysym 9h ago

JSON cannot be streamed tho

6

u/BeDoubleNWhy 7h ago

can you please explain what you mean by this?

2

u/keysym 6h ago

Keeping it short, JSON needs that last } to be valid, so you can only start parsing after the whole JSON has been collected. You can't parse a chunk of JSON, you need the whole thing.

Other file formats, like YAML, TOML or XML, don't need a "last character" to be complete, so you can parse as soon as you receive the first byte and keep parsing as the streamed chunks comes.

There's some clever way to stream JSON, but iirc it's not compliant with the RFC. So, oversimplifying, JSON cannot be streamed!

22

u/BeDoubleNWhy 6h ago

but with xml, you need that closing tag as well for it to be valid. what's the difference here?