Suppose you got a json data, which you do not know structure, but have to analyze... json2qq
is here.
A CLI Tool to extract query templates for jq tool from json data.
Install:
sudo pip3 install git+https://github.com/tos-kamiya/json2jqq.git
Uninstall:
sudo pip3 uninstall json2jqq
Extract a query template for jq
from json data.
$ bash
$ cat > myrepos.json <<EOF
[
{ "author": "Toshihiro Kamiya", "url": "https://github.com/tos-kamiya/json2jqq/" },
{ "author": "Toshihiro Kamiya", "url": "https://github.com/tos-kamiya/giftplayer/" }
]
EOF
$ json2jqq myrepos.json
.[].author
.[].url
Each of extracted queries will work as jq
's filter.
$ jq '.[].url' myrepos.json
"https://github.com/tos-kamiya/json2jqq/"
"https://github.com/tos-kamiya/giftplayer/"
Option -s
will show a sample value for each query.
$ json2jqq -s myrepos.json
.[].author Toshihiro Kamiya
.[].url https://github.com/tos-kamiya/json2jqq/