Jq

Filtra campi, nodi o risultati da documenti strutturati tramite una query.

Input: TestoRisultato: Testo

Inserimento di testo

Esegui per vedere il risultato

Esempi

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]
Dati grezzi
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
Dati grezzi
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
Dati grezzi
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
Dati grezzi
On
Use a full name when the nickname is missing

Input

{"nickname":null,"name":"Ada Lovelace"}

Expected answer

Ada Lovelace
Query
.nickname // .name
Dati grezzi
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 contains
Number exceeds safe precision
Query
.id
Dati grezzi
Off
Select a quoted 64-bit identifier without losing digits

Input

{"id":"18446744073709551615"}

Expected answer

"18446744073709551615"
Query
.id
Dati grezzi
Off
Get JSON Property

Input

{"data": "testString\u0000"}

Expected answer

JSON
"testString\u0000"
Query
.data
Dati grezzi
Off
Get raw JSON Property

Input

{"data": "testString\u0000"}

Expected answer

Hexadecimal bytes
74 65 73 74 53 74 72 69 6e 67 00
Query
.data
Dati grezzi
On

Strumenti correlati

Riordino del codice

Riferimento dell’operazione

Vedi la documentazione tecnica originale (English)