JSONPath Tester (Pick data từ JSON)
Test JSONPath query với JSON sample. Hỗ trợ recursive descent, slice, filter cơ bản. Phù hợp pick data từ API response, debug LLM structured output.
Cú pháp JSONPath
| $ | Root object |
| $.foo / $["foo"] | Property foo |
| $.foo.bar | Nested property |
| $[0] | Phần tử mảng đầu tiên |
| $[-1] | Phần tử cuối |
| $[*] | Tất cả phần tử |
| $[0:3] | Slice 0..2 |
| $..price | Recursive — mọi `price` ở mọi level |
| $.items[?(@.price > 100)] | Filter (subset support) |
Test JSONPath query với JSON sample. Implement JSONPath subset (RFC 9535 draft). Dùng để pick data từ API response, debug structured output LLM.
JSONPath là gì?
JSONPath = "XPath cho JSON". Cú pháp query để extract phần dữ liệu từ JSON object/array. Phổ biến trong:
- Postman: test API response — assert
$.data.users[0].id === 1. - jq (CLI): dùng pattern tương tự để query JSON từ command line.
- AWS CLI:
--query 'Reservations[*].Instances[*].PublicIpAddress'. - OpenSearch / Elasticsearch: query nested fields.
- LangChain / LLM: extract structured output từ LLM response.
Cú pháp tóm tắt
$— root.$.foohoặc$["foo"]— property.$[0]— index,$[-1]— last.$[*]— tất cả phần tử/property.$[0:3]— slice.$..price— recursive descent (mọipriceở mọi level).$.items[?(@.price > 100)]— filter.
Use case thực tế
// API response
{
"store": {
"books": [
{ "title": "AI for Everyone", "price": 350000 },
{ "title": "Sapiens", "price": 280000 }
]
}
}
// Lấy tất cả title:
$.store.books[*].title // ["AI for Everyone", "Sapiens"]
// Lấy book có giá > 300k:
$.store.books[?(@.price > 300000)]
// Recursive — mọi price trong document:
$..price // [350000, 280000] JSONPath vs JSON Pointer (RFC 6901)
- JSONPath: query language — flexible, có wildcard, filter.
- JSON Pointer (
/foo/0/bar): chỉ trỏ tới 1 location cụ thể, không có wildcard.
Phù hợp với ai
Backend dev, API integrator, người debug response JSON/YAML/CSV, hoặc làm việc với dữ liệu cấu trúc thường xuyên.
Câu hỏi thường gặp
Dữ liệu nhạy cảm có an toàn không?
Có. JSON/YAML/CSV bạn paste KHÔNG được upload lên server. Mọi xử lý (parse, format, validate) diễn ra cục bộ trong trình duyệt.
Có giới hạn dung lượng dữ liệu không?
Phụ thuộc vào RAM trình duyệt. Thông thường file dưới 10MB chạy mượt. File lớn hơn có thể chậm hoặc đứng tab.
Công cụ liên quan
Xem tất cả công cụ →JWT Decoder
Decode JWT token, xem header/payload/claims với thời gian dễ đọc.
MỚIFormat JSON
Format / minify / validate JSON. Sort key A-Z, custom indent, phím tắt Ctrl+Enter.
MỚIUUID / Hash / Base64 / URL
Bundle 4 dev tool: UUID v4, SHA-256/512 hash, Base64 (URL-safe), URL encode.
MỚIĐổi cơ số (DEC/HEX/BIN/OCT)
Convert giữa cơ số 2-36 + ASCII codes. BigInt support. Phù hợp debug bitwise, CS101, đọc memory dump.