3 ms·
+1 - If you are looking for something JSON-compatible, JSON Lines (one json object per line - https://jsonlines.org/ https://jsonlines.org/) is pretty popular a
by scrollaway 5y ago
+1 - If you are looking for something JSON-compatible, JSON Lines (one json object per line - https://jsonlines.org/ https://jsonlines.org/) is pretty popular as well.
You could store a CSV in JSONL very easily. In fact, jsonlines' website shows it as its first example: https://jsonlines.org/examples/ https://jsonlines.org/examples/
And if you wanted something that is json file-wide, you can just add some commas and wrap in [] for a list of rows.
- DangitBobby 5y agoOh no, this is so similar to http://ndjson.org/ http://ndjson.org/
- boygobbo 5y agondjson appears to be a fork of jsonlines with the addition of a spec (see https://github.com/ndjson/ndjson.github.io/issues/1 https://github.com/ndjson/ndjson.github.io/issues/1)
- hnlmorg 5y agojsonlines (and ndjson too, since they're overlapping specs) is amazing. It's definitely the better way to convert between JSON and CSV. » ps aux | grep root | head -n5 | format jsonl ["root","87596","0.0","0.0","4359648","116","??","Ss","10:01am","0:00.02","com.apple.cmio.registerassistantservice"] ["root","81777","0.0","0.0","4321932","88","??","Ss","Wed12am","0:00.01","PlugInLibraryService"] ["root","71784","0.0","0.1","4365572","10504","??","Ss","Tue11pm","0:25.88","PerfPowerServices"] ["root","42906","0.0","0.0","4321572","88","??","Ss","Tue09am","0:00.01","com.apple.ColorSyncXPCAgent"] ["root","47415","0.0","0.0","4303172","88","??","Ss","Sat04am","0:00.01","aslmanager"] It has the readability of CSV but the stricter formatting of JSON. Win win.
- aae42 5y agoi've known about json lines for a bit (had to make a utility that parsed some output of a program that used jsonlines and was irritated it didn't use the json spec)... but for some reason just this post made me realize something... i've always been irritated by CSV log files (or space delimited), but would prefer something more structured like JSON, but JSON log files are pretty obnoxious for the reasons mentioned in the comments, a lot of data duplication... JSON lines for log files seems like a great fit, not sure why i didn't realize this until now, i suppose it was the context of the discussion!