JSON
ทดสอบ JSONPath
ทดสอบนิพจน์ JSONPath กับข้อมูล JSON จริง — ดูตัวอย่างค่าที่พบและเส้นทางของค่าเหล่านั้นทันที
$ — ราก · .key / ['key'] — พร็อพเพอร์ตี้ · .. — ค้นหาแบบเรียกซ้ำ · [*] — ทุกอิลิเมนต์ · [0,1] — ดัชนี · [0:2] — สไลซ์ · [?(@.price<10)] — ตัวกรอง
—
JSONPath lets you reach into nested JSON values the way XPath does for XML — a compact path string like $.users[0].email instead of manually walking the structure. This tool lets you test an expression against real data and see the result instantly.
How to use it
- Paste JSON data into one field and a JSONPath expression into the other.
- The result shows every matched value along with its exact path, even when there are several matches.
- Use [*] to iterate over every array element, or a filter like [?(@.price > 100)] for conditional selection.
Common uses
- Working out the right JSONPath expression to pull a specific field from an API response before pasting it into code.
- Testing data-transformation or message-routing rules that rely on JSONPath (for example, in AWS Step Functions or an API Gateway).
- Quickly locating a value in a large, deeply nested JSON document without scrolling through it manually.
Things to keep in mind
There's no single official JSONPath standard — the basic syntax (dots, brackets, *) is supported the same way everywhere, but filters and more advanced expressions differ between libraries.
Array indexing in JSONPath starts at zero, like in most programming languages — [0] means the first element.
บทความเกี่ยวกับเครื่องมือนี้: JSONPath: ค้นหาข้อมูลใน JSON โดยไม่ต้องแยกวิเคราะห์เอง
คำถามที่พบบ่อย
นิพจน์ JSONPath อย่าง $.store.book[*].author ทำอะไรกันแน่?
มันเดินทางผ่านโครงสร้าง JSON เริ่มจากรูท ($) ผ่านคีย์ store และ book และไวลด์การ์ด [*] จะเลือกทุกสมาชิกใน array book ก่อนอ่านฟิลด์ author ของแต่ละตัว
$.a.b กับ $..b ต่างกันอย่างไร?
จุดเดียวเข้าถึงพร็อพเพอร์ตี้ลูกโดยตรง ส่วนจุดคู่ (recursive descent) จะค้นหาในทุกระดับความลึกของโครงสร้าง จับคู่กับคีย์ชื่อ b ทุกที่ที่ปรากฏ ไม่ใช่แค่ในฐานะลูกโดยตรง
เครื่องมือนี้ส่ง JSON ของฉันไปที่ไหนเพื่อประเมินเส้นทางหรือไม่?
ไม่ นิพจน์ JSONPath ถูกประเมินทั้งหมดในเบราว์เซอร์ของคุณ ข้อมูลของคุณจะไม่ออกจากอุปกรณ์เลย
ต้องเข้าถึงคีย์ที่มีจุดหรือช่องว่างอย่างไร?
ผ่านวงเล็บเหลี่ยมพร้อมเครื่องหมายคำพูด: $['user.name'] แทนที่จะเป็น $.user.name — มิฉะนั้น parser จะอ่านจุดเป็นตัวแบ่งระดับการซ้อน ไม่ใช่ส่วนหนึ่งของชื่อคีย์
JSONPath มีมาตรฐานทางการเพียงหนึ่งเดียวหรือไม่?
ไม่ ไวยากรณ์พื้นฐาน (จุด วงเล็บ เครื่องหมายดอกจัน) รองรับเหมือนกันแทบทุกที่ แต่ตัวกรองและนิพจน์ขั้นสูงแตกต่างกันไปตามไลบรารี — ควรตรวจสอบความเข้ากันได้สำหรับนิพจน์ที่ซับซ้อน