Examples
List only services that passed their readiness checks
Input
[{"name":"api","ready":true},{"name":"scheduler","ready":false},{"name":"worker","ready":true}]Expected answer
["api","worker"]- Query
[.[] | select(.ready) | .name]- Raw
Off
Add line-item prices without floating-point currency
Amounts are integer cents; the total is 3,750 cents, or $37.50.
Input
[{"item":"storage","cents":1250},{"item":"compute","cents":2400},{"item":"transfer","cents":100}]Expected answer
3750- Query
[.[].cents] | add- Raw
Off
Count requests inside a nested API response
Input
{"page":1,"requests":[{"id":"req-a"},{"id":"req-b"},{"id":"req-c"}]}Expected answer
3- Query
.requests | length- Raw
Off
Copy a release tag without JSON quotation marks
Input
{"release":{"tag":"v2.4.1","draft":false}}Expected answer
v2.4.1- Query
.release.tag- Raw
On
Use a full name when the nickname is missing
Input
{"nickname":null,"name":"Ada Lovelace"}Expected answer
Ada Lovelace- Query
.nickname // .name- Raw
On
Reject an integer jq cannot safely represent
jq uses floating-point numbers. Quote identifiers that exceed its safe integer range.
Input
{"id":9007199254740995}Expected rejection
Message containsNumber exceeds safe precision- Query
.id- Raw
Off
Select a quoted 64-bit identifier without losing digits
Input
{"id":"18446744073709551615"}Expected answer
"18446744073709551615"- Query
.id- Raw
Off
Get JSON Property
Input
{"data": "testString\u0000"}Expected answer
JSON"testString\u0000"- Query
.data- Raw
Off
Get raw JSON Property
Input
{"data": "testString\u0000"}Expected answer
Hexadecimal bytes74 65 73 74 53 74 72 69 6e 67 00- Query
.data- Raw
On
Format reference: Jq background and specification