I don't see what jsonlines has over yaml; in fact the jsonlines examples presented there are almost trivially converted to yaml.
e.g. the first example is valid yaml if you add a '- ' to each line.
And JSON is (almost) a perfect subset of yaml. I've been using csv lately. It's reputation is overstated. What I like is that it's far more compact than yaml or json and trivially pulled into sqlite for ad-hoc queries.
One thing I like about JSON Lines is robustness to bad data - if an individual line is corrupted, you can discard it / print a warning and move on, and the parser can start again at the next newline. This makes it useful for log messages / metrics, because if something crashes while emitting a log line, you can recover. If something crashes while emitting an item in a YAML list, you might corrupt the entire rest of the document.
Another is that it makes streaming processing a little easier. Once you have a line, you know you can attempt to process it, and you can shard processing on newlines without a full YAML processor. Tools that work on newlines or tools that can just split on lines can handle the first level of JSON Lines output.
https://github.com/zacharyvoase/jsonpipe It includes 'jsonunpipe'. So you could grep part of the JSON and still get a JSON back. ```
echo '{"a": 1, "b": 2}' |grep b| jsonpipe | jsonunpipe #{""b": 2}
```
Comments (120) 40 threads
Earlier commentshttps://sqlite.org/json1.html#jtree
Related, if you want more of a csv-style, see JSONLines. aka "newline-delimited JSON"
http://jsonlines.org/
And JSON is (almost) a perfect subset of yaml.
I've been using csv lately. It's reputation is overstated.
What I like is that it's far more compact than yaml or json and trivially pulled into sqlite for ad-hoc queries.
Or spreadsheets, to work out a plan, and then MySQL.
Another is that it makes streaming processing a little easier. Once you have a line, you know you can attempt to process it, and you can shard processing on newlines without a full YAML processor. Tools that work on newlines or tools that can just split on lines can handle the first level of JSON Lines output.
deno install catj https://deno.land/std/examples/catjson.ts --allow-read
https://github.com/zacharyvoase/jsonpipe
It includes 'jsonunpipe'.
So you could grep part of the JSON and still get a JSON back.
``` echo '{"a": 1, "b": 2}' |grep b| jsonpipe | jsonunpipe
#{""b": 2} ```
All comments shown.
Couldn't load more comments. Check your connection and try again.