JSON.sh

a pipeable JSON parser written in Bash

Github星跟踪图

JSON.sh

yo, so it's a json parser written in shell, compatible with ash, bash, dash and zsh

travis

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

Options

-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.

Installation

Install with npm, pip or from AUR on Archlinux:

  • npm install -g JSON.sh
  • pip install git+https://github.com/dominictarr/JSON.sh#egg=JSON.sh
  • yaourt -Sy json-sh
    (json-sh on aur
    thanks to kremlin-)

License

This software is available under the following licenses:

  • MIT
  • Apache 2

主要指标

概览
名称与所有者dominictarr/JSON.sh
主编程语言Shell
编程语言Shell (语言数: 2)
平台
许可证Other
所有者活动
创建于2011-10-24 22:16:53
推送于2020-12-15 18:51:41
最后一次提交2018-12-23 23:27:16
发布数0
用户参与
星数2k
关注者数82
派生数266
提交数106
已启用问题?
问题数29
打开的问题数16
拉请求数21
打开的拉请求数3
关闭的拉请求数7
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?