4 ms·
Maybe you're solving a different problem, but I'm not sure emitting one key-value pair per line is ultimately the way to go: $ echo '[{"a": [{"b": {"c": ["fo
by sigil 16y ago
Maybe you're solving a different problem, but I'm not sure emitting one key-value pair per line is ultimately the way to go:
$ echo '[{"a": [{"b": {"c": ["foo"]}}]}]' | jsonpipe
/ []
/0 {}
/0/a []
/0/a/0 {}
/0/a/0/b {}
/0/a/0/b/c []
/0/a/0/b/c/0 "foo"
In my own work, I've built up a suite of stream-based nested record processing tools that accept & produce JSON, protocol buffers, and a unix tab-delimited format. For the unix format it's been more useful to stick to the standard one-record-per-line thing, and let the user specify what fields to extract and their order.
Here's a depressing example of the fun you can have with new media and old unix tools, to give you some idea:
$ mill io -r json -w texty -W fields=in_reply_to_screen_name < tweets.json | \
grep -v -E '^(None|)$' | sort | uniq -c | sed -e 's#^ *##' | \
sort -k1,1 -nr | head -5
258 justinbieber
248 ddlovato
184 gypsyhearttour
164 Logindaband
145 Louis_Tomlinson