5 comments

[ 5.6 ms ] story [ 14.5 ms ] thread
Its an interesting idea but what does this achieve that jq [1] doesn't already do, and likely faster?

[1] http://stedolan.github.io/jq/

the 20 lines thing... :P

it was a challenge to write, bash has nothing that looks like a recursive data structure. it's not really meant to be useful ^^

Looking at the source[1] it stands at 94 lines. There's also no example of field extraction in the readme even though it's mentioned that there is an example below in the features section.

[1] https://github.com/izabera/j/blob/master/j

the parser is 20 lines. then there's a function named print, then there's a for loop that extracts the fields. the last two lines of the readme are the example you're looking for:

$ ./j 'obj->"foo"' 'arr->1' 'obj->"baz"' <<< '{"foo":["bar",{"baz":"bat"}]}'

"bat"