DEV Community

Format stack
Format stack

Posted on

Most JSONPath Testers Hide the One Thing You Need

Run $..price in most online JSONPath testers and you get this:

[8.95, 12.99, 8.99, 22.99, 19.95]
Enter fullscreen mode Exit fullscreen mode

Five numbers. Which one is the bicycle? You end up counting array indexes by hand.

I built a tester that shows where each result came from:

$.store.book[0].price     8.95
$.store.book[1].price     12.99
$.store.book[2].price     8.99
$.store.book[3].price     22.99
$.store.bicycle.price     19.95
Enter fullscreen mode Exit fullscreen mode

Every path is copy-pasteable into your code.

Two more things it does differently

  • No type coercion. "10" sorts before "9" as a string, so a filter that quietly coerces your IDs works on test data and breaks at double digits. This one returns no match instead of a wrong one.

  • Bad expressions fail loudly. You get an error with a position, not an empty result you have to guess about.

It follows RFC 9535, runs in your browser, and has no dependencies.

Try it: formatstack.tech/tools/json-query

Want the parser bug that ate my whole day? It's in the full build notes.

Which JSONPath tool do you use, and has it ever returned the wrong match?

Top comments (0)