jq2
extract json data
install
npm install -g jq2
usage
jq2 <lookupstring> [filename]
if no filename is provided it will use stdin.
$
in the <lookupstring>
is a reference to the javascript object.
examples
echo '{"a": {"b": [ 123 ]}}' | jq2 '$.a.b[0]' #123 echo '{"a": {"b": [ 123 ]}}' | jq2 'Math.pow($.a.b[0], 2)' #15129 echo '[" foo bar "," baz "]' | jq2 '$.map(s => s.trim()).join("")' #foo barbaz # lodash is included so this will work too echo '[" foo bar ", " baz "]' | jq2 '$.map(_.trim).join("")' #foo barbaz echo '{"a": 123}' > file.jsonjq2 '$.a' file.json #123