Hacker News new | ask | show | jobs
by jlas 846 days ago
It's useful for streaming data where you want to pass small chunks of data incrementally. JSON by itself isn't streamable (you need the entire blob to decode it). But if we just pass smaller json-encoded chunks of data and separate them with a newline, we can make a streaming-compatible JSON protocol.
1 comments

> It's useful for streaming data where you want to pass small chunks of data incrementally. JSON by itself isn't streamable (you need the entire blob to decode it).

What's wrong with JSON patch?

https://jsonpatch.com/

JSON Patch is incremental updates to a singular JSON document[1].

Lines-of-JSON is streaming delivery of multiple JSON documents. Most producers & consumers will only hold one item in memory at a time.

[1]: And kinda sucks at that job. Last time I benchmarked it, a gzipped lines-of-json stream that just repeated the whole document for every edit was smaller than a JSON Patch stream, and re-parsing the document was faster than applying JSON Patches.