JQ: Difference between revisions
From DWIKI
m →Links Tag: wikieditor |
m →FAQ Tag: wikieditor |
||
| (10 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
JSON processor | JSON processor | ||
=Links= | =Links= | ||
*[https://gist.github.com/olih/f7437fb6962fb3ee9fe95bda8d2c8fa4 jq | *https://devdocs.io/jq/ | ||
*[https://gist.github.com/olih/f7437fb6962fb3ee9fe95bda8d2c8fa4 jq cheat sheet] | |||
*https://jqlang.github.io/jq/ | *https://jqlang.github.io/jq/ | ||
*[https://towardsdev.com/using-jq-to-fetch-key-value-from-json-output-a83ccbec2be9 some nice jq trickery] | *[https://towardsdev.com/using-jq-to-fetch-key-value-from-json-output-a83ccbec2be9 some nice jq trickery] | ||
*[https://www.digitalocean.com/community/tutorials/how-to-transform-json-data-with-jq How To Transform JSON Data with jq] | |||
=Related tools= | |||
* gron | |||
* yq | |||
=Examples= | =Examples= | ||
==get value of just one field== | |||
==Get the keys form key/value pairs== | |||
jq '.[] | to_entries[] .key' | |||
==get value of just one field, by name== | |||
jq '.[].fieldname' | |||
or when hyphen in name | |||
jq '.[]."field-name"' | |||
or just | |||
jq '.fieldname' | |||
=FAQ= | |||
==Error messages== | |||
===parse error: Invalid numeric literal at line 1=== | |||
In case of python outpout try | |||
print(json.dumps(yourjson)) | |||
===jq: parse error: Objects must consist of key:value pairs=== | |||
I got that when i tried | |||
[{ | |||
{ "name":"foo","value":"bar"} | |||
}] | |||
use | |||
[ | |||
] | |||
instead | |||
Latest revision as of 12:19, 14 April 2026
JSON processor
Links
- https://devdocs.io/jq/
- jq cheat sheet
- https://jqlang.github.io/jq/
- some nice jq trickery
- How To Transform JSON Data with jq
Related tools
- gron
- yq
Examples
Get the keys form key/value pairs
jq '.[] | to_entries[] .key'
get value of just one field, by name
jq '.[].fieldname'
or when hyphen in name
jq '.[]."field-name"'
or just
jq '.fieldname'
FAQ
Error messages
parse error: Invalid numeric literal at line 1
In case of python outpout try
print(json.dumps(yourjson))
jq: parse error: Objects must consist of key:value pairs
I got that when i tried
[{
{ "name":"foo","value":"bar"}
}]
use
[ ]
instead
