yo, so it's a json parser written in shell, compatible with ash, bash, dash and zsh
pipe json to it, and it traverses the json objects and prints out the path to the current object (as a JSON array) and then the object, without whitespace.
$ json_parse < package.json
["name"] "JSON.sh"
["version"] "0.0.0"
["description"] ""
["homepage"] "http://github.com/dominictarr/JSON.sh"
["repository","type"] "git"
["repository","url"] "https://github.com/dominictarr/JSON.sh.git"
["repository"] {"type":"git","url":"https://github.com/dominictarr/JSON.sh.git"}
["bin","json_parse"] "./JSON.sh"
["bin"] {"json_parse":"./JSON.sh"}
["dependencies"] {}
# ... etc
a more complex example:
curl registry.npmjs.org/express | ./JSON.sh | egrep '\["versions","[^"]*"\]'
... try it and see
-b
Brief output. Combines 'Leaf only' and 'Prune empty' options.
-l
Leaf only. Only show leaf nodes, which stops data duplication.
-p
Prune empty. Exclude fields with empty values.
-n
No-head. Don't show nodes that have no path. Normally these output a leading '[]', which you can't use in a bash array.
-s
Remove escaping of the solidus symbol (stright slash).
-h
Show help text.
Install with npm, pip or from AUR on Archlinux:
npm install -g JSON.shpip install git+https://github.com/dominictarr/JSON.sh#egg=JSON.shyaourt -Sy json-sh
(json-sh on aur
thanks to kremlin-)This software is available under the following licenses:
Overall
Maintained
Code review
npm
Latest release
Releases this year
2,550 followers · starred Oct 2011
43 followers · starred Aug 2017
373 followers · starred Oct 2011
572 followers · starred Apr 2015
yo, so it's a json parser written in shell, compatible with ash, bash, dash and zsh
pipe json to it, and it traverses the json objects and prints out the path to the current object (as a JSON array) and then the object, without whitespace.
$ json_parse < package.json
["name"] "JSON.sh"
["version"] "0.0.0"
["description"] ""
["homepage"] "http://github.com/dominictarr/JSON.sh"
["repository","type"] "git"
["repository","url"] "https://github.com/dominictarr/JSON.sh.git"
["repository"] {"type":"git","url":"https://github.com/dominictarr/JSON.sh.git"}
["bin","json_parse"] "./JSON.sh"
["bin"] {"json_parse":"./JSON.sh"}
["dependencies"] {}
# ... etc
a more complex example:
curl registry.npmjs.org/express | ./JSON.sh | egrep '\["versions","[^"]*"\]'
... try it and see
-b
Brief output. Combines 'Leaf only' and 'Prune empty' options.
-l
Leaf only. Only show leaf nodes, which stops data duplication.
-p
Prune empty. Exclude fields with empty values.
-n
No-head. Don't show nodes that have no path. Normally these output a leading '[]', which you can't use in a bash array.
-s
Remove escaping of the solidus symbol (stright slash).
-h
Show help text.
Install with npm, pip or from AUR on Archlinux:
npm install -g JSON.shpip install git+https://github.com/dominictarr/JSON.sh#egg=JSON.shyaourt -Sy json-sh
(json-sh on aur
thanks to kremlin-)This software is available under the following licenses:
Overall
Maintained
Code review
npm
Latest release
Releases this year
2,550 followers · starred Oct 2011
43 followers · starred Aug 2017
373 followers · starred Oct 2011
572 followers · starred Apr 2015