Utvikling · verktøy

JSONPath-spørringsverktøy

Lim inn JSON og et JSONPath-uttrykk for å hente samsvarende verdier.

Kjøres i nettleseren. Ingen opplasting.

Values are processed locally in this browser.

Result

—

Om verktøyet

JSONPath-spørringsverktøy sem complicação.

Støtter rot, egenskaper med punktum eller hakeparenteser, matriseindekser, jokertegn og enkle likhetsfiltre som $[?(@.active == true)]. Verktøyet kjører ikke JavaScript og laster ikke inn eksterne data.

Veiledning

Slik bruker du JSONPath-spørringsverktøy

The JSONPath Query Tool pulls values out of a block of JSON. You paste the JSON, type a path such as $.users[*].name, and press Calculate to see what matches, formatted with two-space indentation. It handles a small, safe subset of JSONPath: property names, array positions, wildcards and simple equality filters. It never runs code from your data and never loads anything from the web.

Slik gjør du

  1. Paste your JSON into the JSON data box. It must be valid, with double-quoted keys and no trailing commas, or the tool reports a JSON error.
  2. Type a path that starts with $, the root of the data. The box starts with $.users[*].name. Paths can be up to 500 characters.
  3. Build the path from dots and brackets: .name for a property, [0] for an array position, [*] or .* for every child, ["key"] for awkward names, and a filter like [?(@.active == true)].
  4. Press Calculate to see the result. Clear empties the form. Copy result puts the text on your clipboard.

Eksempler

Every title in a list

Du skriver inn
JSON-data
{"shop":{"books":[{"title":"A","price":8},{"title":"B","price":12},{"title":"C","price":8}]}}
Bane
$.shop.books[*].title
Du får
Verdi
Støttede syntaksformer: [0], ["key"], [*] og enkle likhetsfiltre.

The [*] visits each book, and .title takes the title from each. Several matches come back as a list.

Kjørt med verktøyets egen kode.

Keep only items that match a value

Du skriver inn
JSON-data
{"shop":{"books":[{"title":"A","price":8},{"title":"B","price":12},{"title":"C","price":8}]}}
Bane
$.shop.books[?(@.price == 8)].title
Du får
Verdi
[ "A", "C" ]

The filter keeps the books whose price is exactly 8. Then .title takes their titles. Comparing 8 with the text "8" would not match, since the types must agree.

Kjørt med verktøyets egen kode.

A comparison the tool does not support

Du skriver inn
JSON-data
{"shop":{"books":[{"title":"A","price":8},{"title":"B","price":12}]}}
Bane
$.shop.books[?(@.price > 10)].title
Du får
Verdi
Supported brackets: [0], ["key"], [*] and simple equality filters.

Only == and != are accepted inside a filter. A greater-than test is refused with this message, and nothing is evaluated.

Kjørt med verktøyets egen kode.

Når det er nyttig

  • Pull one field out of a long API response while debugging.
  • Check that a path you plan to use in code selects the values you expect.
  • List every value of one key across an array of records.
  • Filter records by a flag, such as active equal to true, to count or inspect them.

Begrensninger

  • Only a subset is supported. Recursive descent (..), slices like [0:2], unions like [0,1], negative indexes and comparisons such as > or < are not available.
  • Filters accept only @.key == value or @.key != value, where the value is valid JSON such as true, 3, null or "text". Single-quoted text is not valid there.
  • If exactly one value matches, it is shown on its own and not inside a list. If nothing matches, the result reads No matches.
  • The query stops with a message if it would return more than 10,000 values, and the path itself cannot be longer than 500 characters.

Tips

  • Start with $ alone to confirm the JSON parsed, then add one segment at a time and watch the result narrow.
  • Use ["key"] for names with spaces or other odd characters, such as $.shop["first name"].
  • Remember that one match is not wrapped in a list when you copy a result into code that expects an array.

Kilder

Vanlige spørsmål

Sobre JSONPath-spørringsverktøy.

What is JSONPath?

It is a query language for JSON, similar in spirit to XPath for XML. A path starting with $ walks through objects and arrays to select values. A full standard exists as RFC 9535, and this tool covers a small part of it.

Which JSONPath features does this tool support?

The root $, dot and bracket property names, array positions like [0], the wildcard [*] or .*, and filters of the form [?(@.key == value)] or != value. It does not run scripts and it does not fetch data from the internet.

Why does my path with .. give an error?

The two-dot form selects values at any depth, which the tool does not implement. It stops with a message about recursive descent. Write the full path step by step instead, for example $.store.users[*].name.

Why can I not filter by price greater than 10?

The filter engine only compares for equality or inequality. A greater-than or less-than test is rejected. A workaround is to extract the values with [*] and compare them in your own code or another tool.

Why do I get a value instead of a list?

When a path matches exactly one value, the tool shows that value alone. When it matches several, it shows a list. When nothing matches, it says No matches. Keep this in mind when comparing results from different paths.

Why does the JSON fail to load?

The text must be strict JSON. Keys need double quotes, strings need double quotes, trailing commas are not allowed and comments are not allowed. The error message from the parser usually names the position where it stopped.

Is my JSON sent anywhere?

No. The query runs in your browser and the data is not uploaded. The tool does not execute JavaScript from your data. The page forgets the content when you reload it, so copy any result you want to keep.

Hvordan bruker du JSONPath-spørringsverktøy?

Lim inn JSON og et JSONPath-uttrykk for å hente samsvarende verdier.

Lastes dataene mine opp til en server?

Nei. Behandlingen skjer i nettleseren din, og opplysningene dine lastes ikke opp.