I’ve seen how certain standards and tools become indispensable when working with data. And if there’s one thing we’ve learned over these years, it’s that JSON is everywhere: APIs, logs, configurations, NoSQL databases… The question is no longer whether you’ll work with JSON, but when you’ll face that 15-level nested structure that makes you sigh.
The Problem We’ve All Lived Through
How many times have you had to write something like this?
// The typical code we've all written
const book = data.store.book[0];
const price = book ? book.price : null;
const author = book && book.authors ? book.authors[0] : null;
Or worse yet, those nested loops to filter arrays within objects within arrays. It’s tedious, error-prone, and, frankly, not very elegant.
JSONPath: The Solution We Were Waiting For
Recently I came across this excellent article on PostPilot that explains JSONPath very clearly. And the truth is, it reminded me of something fascinating: JSONPath just became an official standard with the publication of RFC 9535 in 2024.
The curious thing? It’s been 17 years since Stefan Gössner published his original blog post about JSONPath in 2007. Seventeen years for a brilliant idea to become a standard. This reminds me why I always say that “for every minute you dedicate to planning and study, you’ll need 2 minutes less of development”.
What is JSONPath Really?
JSONPath is like XPath but for JSON. It allows you to make declarative queries on complex JSON structures using a simple and expressive syntax.
Instead of writing imperative code, you simply describe what data you want:
// Instead of complex loops
const titles = jp.query(data, '$.store.book[*].title');
// ["The Catcher in the Rye", "To Kill a Mockingbird", "Sapiens"]
// Filters with conditions
const expensiveBooks = jp.query(data, '$..book[?(@.price > 10)]');
// Recursive searches
const allExistingPrices = jp.query(data, '$..price');
Practical Syntax (The Stuff You Really Use)
After years working with different technologies, I’ve learned that what matters isn’t memorizing the entire syntax, but understanding the most useful patterns:
The Essential Basics:
$- The root node (like/in XPath)$.store.book- Property navigation$.store.book[0]- Array element access$.store.book[*]- All elements of an array$..price- Recursive search (allpriceat any level)
The Filters You Actually Use:
$..book[?(@.price > 10)]- Filter by condition$..book[?(@.isbn)]- Filter by property existence$..book[?(@.category=='fiction')]- Filter by exact value
The Useful Functions (RFC 9535):
length()- Size of arrays, objects, or stringsmatch()- Complete regular expressionssearch()- Search for substringcount()- Count matching elements
Tools That Will Make Your Life Easier
One of the things I like most about JSONPath is the ecosystem of tools that have emerged around it. Here are some I recommend:
Online playgrounds:
- JSONPath.com - Simple and direct
- JSONPath Tester by Curious Concept - Multiple implementations
- Mockoon JSONPath Evaluator - With real-time updates
- PostPilot.dev - The one mentioned in the original article
Implementations by language:
- JavaScript:
jsonpath(npm) - Python:
jsonpath-ng - Java:
com.jayway.jsonpath - C#:
JsonPath.Net - Go: Various RFC 9535 implementations like jsonpath
- PHP: jsonpath-php with RFC 9535 support
My Practical Experience
In recent projects where I’ve worked with complex APIs and structured data, JSONPath has saved me hours of development. It’s especially useful when:
- Processing API responses where you need to extract specific data
- Working with configurations that change frequently
- Analyzing logs in JSON format where you’re looking for specific patterns
- Transforming data before storing or sending to other systems
The Future is Here
What I find most interesting is that now, with RFC 9535, we finally have an official standard. This means implementations will converge toward a common syntax, which is excellent news for interoperability.
As I always say: “There’s no such thing as a good solution/technology for everything,” but JSONPath is definitely a tool that should be in your arsenal if you work with JSON regularly.
Resources to Go Deeper
- RFC 9535 - Official JSONPath
- Original PostPilot article - Excellent practical explanation
- JSONPath Comparison Project - Compares different implementations
- Stefan Gössner’s historical blog post - Where it all began in 2007
Personal Conclusion
JSONPath is one of those tools that, once you incorporate into your workflow, you wonder how you lived without it. It’s elegant, powerful, and now that it’s an official standard, a safe bet for the future.
As always, the best way to learn is by practicing. I recommend trying some of the online playgrounds with your own JSON data and seeing how JSONPath can simplify your code.
Have you used JSONPath in your projects before? What use cases have you found most useful? I’d love to hear about your experience.
Did you find this article useful? Share it with other developers who could benefit from JSONPath. And if you have any questions or experiences to share, don’t hesitate to contact me.










Comments