JQ Tool: Difference between revisions
Jump to navigation
Jump to search
| (8 intermediate revisions by the same user not shown) | |||
| Line 26: | Line 26: | ||
brew update | brew update | ||
brew install jq | brew install jq | ||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" colspan="3"| | |||
<syntaxhighlight lang="bash"> | |||
apt info moreutils | |||
apt search moreutils | |||
sudo apt-get install -y moreutils | |||
</syntaxhighlight> | |||
|} | |} | ||
== | ==Playground== | ||
< | {|class='wikitable mw-collapsible' | ||
!scope='col' style='width:1400px'| | |||
'''JQ » Playground''' | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang="bash"> | |||
jq -r '.auths."hub.chorke.org".auth' ~/.docker/config.json|base64 --decode && echo | jq -r '.auths."hub.chorke.org".auth' ~/.docker/config.json|base64 --decode && echo | ||
jq -r '.auths."reg.chorke.org".auth' ~/.docker/config.json|base64 --decode && echo | jq -r '.auths."reg.chorke.org".auth' ~/.docker/config.json|base64 --decode && echo | ||
</ | </syntaxhighlight> | ||
---- | |||
< | <syntaxhighlight lang="bash"> | ||
echo -E "$(jq '."terminal.integrated.fontFamily"="Source Code Pro for Powerline"'\ | echo -E "$(jq '."terminal.integrated.fontFamily"="Source Code Pro for Powerline"'\ | ||
${HOME}/.config/Code/User/settings.json)">\ | ${HOME}/.config/Code/User/settings.json)">\ | ||
${HOME}/.config/Code/User/settings.json | ${HOME}/.config/Code/User/settings.json | ||
</ | </syntaxhighlight> | ||
---- | |||
< | <syntaxhighlight lang="bash"> | ||
cat ~/.docker/config.json|yq -P 'del(.auths["harbor.shahed.biz"])' | |||
cat ~/.docker/config.json|jq -r 'del(.auths["harbor.shahed.biz"])' | |||
cat ~/.docker/config.json|jq -r 'del(.auths["harbor.shahed.biz"])'|sponge ~/.docker/config.json | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="bash"> | |||
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.' | (curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.' | ||
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.page|keys' | (curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.page|keys' | ||
| Line 50: | Line 70: | ||
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq --raw-output '.page.updated_at' | (curl -s https://www.githubstatus.com/api/v2/status.json)|jq --raw-output '.page.updated_at' | ||
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.status.indicator,.page.updated_at' | (curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.status.indicator,.page.updated_at' | ||
</ | </syntaxhighlight> | ||
---- | |||
< | <syntaxhighlight lang="bash"> | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '.features |length' | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '.features |length' | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '.features[0:1][0].properties |keys' | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '.features[0:1][0].properties |keys' | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '{type: .type , features: .features}' | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '{type: .type , features: .features}' | ||
</ | </syntaxhighlight> | ||
---- | |||
< | <syntaxhighlight lang="bash"> | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|min' | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|min' | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|max' | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|max' | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.economy]|unique' | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.economy]|unique' | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.economy]|unique[]' | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.economy]|unique[]' | ||
</ | </syntaxhighlight> | ||
---- | |||
< | <syntaxhighlight lang="bash"> | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort' | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort' | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort[]'|head | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort[]'|head | ||
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort[]'|tail | (curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort[]'|tail | ||
</ | </syntaxhighlight> | ||
---- | |||
< | <syntaxhighlight lang="bash"> | ||
(curl -s https://auth.academia.chorke.org/identity/users/login -X POST -H 'Content-Type: application/json'\ | (curl -s https://auth.academia.chorke.org/identity/users/login -X POST -H 'Content-Type: application/json'\ | ||
-d '{"user": "academia","pass": "sadaqah!"}')|jq '.modules[]|select(.id==15)' | -d '{"user": "academia","pass": "sadaqah!"}')|jq '.modules[]|select(.id==15)' | ||
| Line 77: | Line 97: | ||
(curl -s https://auth.academia.chorke.org/identity/users/login -X POST -H 'Content-Type: application/json'\ | (curl -s https://auth.academia.chorke.org/identity/users/login -X POST -H 'Content-Type: application/json'\ | ||
-d '{"user": "academia","pass": "sadaqah!"}')|jq '.permissions[]|select(.name=="View Audit Log")' | -d '{"user": "academia","pass": "sadaqah!"}')|jq '.permissions[]|select(.name=="View Audit Log")' | ||
</ | </syntaxhighlight> | ||
|} | |||
==References== | ==References== | ||
{| | {| | ||
| valign="top" | | | valign="top" | | ||
* [https://medium.com/how-tos-for-coders/https-medium-com-how-tos-for-coders-parse-json-data-using-jq-and-curl-from-command-line-5aa8a05cd79b Parse JSON data | * [https://stackoverflow.com/questions/42716734/ JQ » JSON file in-place] | ||
* [https:// | * [https://medium.com/how-tos-for-coders/https-medium-com-how-tos-for-coders-parse-json-data-using-jq-and-curl-from-command-line-5aa8a05cd79b JQ » Parse JSON data] | ||
* [ | * [https://stedolan.github.io/jq/ JQ] | ||
* [ | |||
| valign="top" | | |||
| valign="top" | | |||
|- | |||
| colspan="3" | | |||
---- | |||
|- | |||
| valign="top" | | |||
* [[YQ Tool]] | |||
* [[HTTPie]] | |||
* [[TMux]] | * [[TMux]] | ||
* [[Wrk]] | |||
| valign="top" | | |||
| valign="top" | | | valign="top" | | ||
|} | |} | ||
Latest revision as of 11:19, 25 July 2025
ubuntu: sudo apt update sudo apt list --upgradable sudo apt upgrade sudo apt install jq sudo apt --fix-broken install |
windows: 1. Press ⊞ + R 2. Type in PowerShell run as administrator user 3. Press Ctrl + Shift + Enter 4. Choose Yes and Press Enter 5. chocolatey install jq |
macos: brew doctor brew update brew install jq |
|
| ||
apt info moreutils
apt search moreutils
sudo apt-get install -y moreutils
| ||
Playground
|
JQ » Playground |
|---|
jq -r '.auths."hub.chorke.org".auth' ~/.docker/config.json|base64 --decode && echo
jq -r '.auths."reg.chorke.org".auth' ~/.docker/config.json|base64 --decode && echo
echo -E "$(jq '."terminal.integrated.fontFamily"="Source Code Pro for Powerline"'\
${HOME}/.config/Code/User/settings.json)">\
${HOME}/.config/Code/User/settings.json
cat ~/.docker/config.json|yq -P 'del(.auths["harbor.shahed.biz"])'
cat ~/.docker/config.json|jq -r 'del(.auths["harbor.shahed.biz"])'
cat ~/.docker/config.json|jq -r 'del(.auths["harbor.shahed.biz"])'|sponge ~/.docker/config.json
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.'
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.page|keys'
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.page|keys[]'
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.page|length'
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '{page: .page}'
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.status|keys[]'
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq --raw-output '.page.updated_at'
(curl -s https://www.githubstatus.com/api/v2/status.json)|jq '.status.indicator,.page.updated_at'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '.features |length'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '.features[0:1][0].properties |keys'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '{type: .type , features: .features}'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|min'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|max'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.economy]|unique'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.economy]|unique[]'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort'
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort[]'|head
(curl -s 'https://raw.githubusercontent.com/datasets/geo-boundaries-world-110m/master/countries.geojson')|jq '[.features[].properties.pop_est]|sort[]'|tail
(curl -s https://auth.academia.chorke.org/identity/users/login -X POST -H 'Content-Type: application/json'\
-d '{"user": "academia","pass": "sadaqah!"}')|jq '.modules[]|select(.id==15)'
(curl -s https://auth.academia.chorke.org/identity/users/login -X POST -H 'Content-Type: application/json'\
-d '{"user": "academia","pass": "sadaqah!"}')|jq '.permissions[]|select(.name=="View Audit Log")'
|
References
|
| ||