Query a JSON API response in Java to extract specific fields without writing custom parsing loops.
Filter items in a JSON array by a condition, such as finding all products priced below a given amount.
Calculate the sum, average, or count of numeric fields in a JSON document using built-in path functions.
Navigate deeply nested JSON structures with a single expression instead of multiple chained object accesses.
Version 3.0.0 requires Java 17 or newer, projects on older Java must use an earlier release.
Jayway JsonPath is a Java library that lets developers read and query data out of JSON documents using a path expression syntax. JSON is a common text format used to exchange data between systems, and JsonPath gives you a way to point at specific parts of a JSON document without writing loops or custom parsing code. The concept is similar to how XPath works for XML documents: you write a short expression that describes where the data lives, and the library fetches it. Path expressions start with a dollar sign representing the root of the document, then navigate down using dot notation or bracket notation. For example, to get the title of the first book in a list, you would write something like $.store.book[0].title. The library also supports wildcards to grab all items in a collection, deep scans to search through nested objects, array slicing, and filter expressions that select items matching a condition, such as all books costing less than a certain price. Several built-in functions are available at the end of a path expression, covering common operations like finding the minimum, maximum, average, or sum of a set of numbers, getting the length of an array, or retrieving the first or last element. You can also apply filter operators that compare values, check membership in a list, test against a regular expression, or check whether a field is empty. The library is available through Maven Central, the standard repository for Java dependencies, by adding a few lines to a project's build file. Version 3.0.0 requires Java 17 or newer. Support questions are handled on Stack Overflow using the jsonpath and java tags. This is a port of the original JsonPath specification created by Stefan Goessner, adapted for use in Java applications.
← json-path on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.