Jq

쿼리 표현식으로 구조화된 문서의 필드나 노드를 추출합니다.

입력: 텍스트결과: 텍스트

텍스트 입력

실행하면 결과가 표시됩니다

예제

List only services that passed their readiness checks

입력

[{"name":"api","ready":true},{"name":"scheduler","ready":false},{"name":"worker","ready":true}]

Expected answer

["api","worker"]
쿼리
[.[] | select(.ready) | .name]
원시 데이터
Off
Add line-item prices without floating-point currency

Amounts are integer cents; the total is 3,750 cents, or $37.50.

입력

[{"item":"storage","cents":1250},{"item":"compute","cents":2400},{"item":"transfer","cents":100}]

Expected answer

3750
쿼리
[.[].cents] | add
원시 데이터
Off
Count requests inside a nested API response

입력

{"page":1,"requests":[{"id":"req-a"},{"id":"req-b"},{"id":"req-c"}]}

Expected answer

3
쿼리
.requests | length
원시 데이터
Off
Copy a release tag without JSON quotation marks

입력

{"release":{"tag":"v2.4.1","draft":false}}

Expected answer

v2.4.1
쿼리
.release.tag
원시 데이터
On
Use a full name when the nickname is missing

입력

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

Expected answer

Ada Lovelace
쿼리
.nickname // .name
원시 데이터
On
Reject an integer jq cannot safely represent

jq uses floating-point numbers. Quote identifiers that exceed its safe integer range.

입력

{"id":9007199254740995}

Expected rejection

Message contains
Number exceeds safe precision
쿼리
.id
원시 데이터
Off
Select a quoted 64-bit identifier without losing digits

입력

{"id":"18446744073709551615"}

Expected answer

"18446744073709551615"
쿼리
.id
원시 데이터
Off
Get JSON Property

입력

{"data": "testString\u0000"}

Expected answer

JSON
"testString\u0000"
쿼리
.data
원시 데이터
Off
Get raw JSON Property

입력

{"data": "testString\u0000"}

Expected answer

Hexadecimal bytes
74 65 73 74 53 74 72 69 6e 67 00
쿼리
.data
원시 데이터
On

관련 도구

코드 정리

작업 참고 자료

원본 기술 문서 보기 (English)