explaingit

json-path/jsonpath

9,411JavaAudience · developerComplexity · 2/5Setup · easy

TLDR

Jayway JsonPath is a Java library that lets you extract specific values from JSON documents using short path expressions, similar to how XPath works for XML, without writing custom parsing loops.

Mindmap

mindmap
  root((jsonpath))
    What it does
      JSON querying
      Path expressions
      Filter conditions
    Tech Stack
      Java
      Maven Central
    Use Cases
      Extract nested values
      Filter arrays
      Aggregate numbers
    Syntax
      Dot notation
      Wildcard selectors
      Deep scan
    Functions
      min max avg
      length and size
      first and last
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Query a JSON API response in Java to extract specific fields without writing custom parsing loops.

USE CASE 2

Filter items in a JSON array by a condition, such as finding all products priced below a given amount.

USE CASE 3

Calculate the sum, average, or count of numeric fields in a JSON document using built-in path functions.

USE CASE 4

Navigate deeply nested JSON structures with a single expression instead of multiple chained object accesses.

Tech stack

JavaMaven

Getting it running

Difficulty · easy Time to first run · 30min

Version 3.0.0 requires Java 17 or newer, projects on older Java must use an earlier release.

In plain English

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.

Copy-paste prompts

Prompt 1
Show me how to use Jayway JsonPath in Java to extract all book titles from a nested JSON store object.
Prompt 2
Write a Java example using JsonPath to filter a list of items and return only those where the price is less than 10.
Prompt 3
How do I add Jayway JsonPath to a Maven project and use it to get the first element of a JSON array?
Prompt 4
Show me how to use the min, max, and avg functions in a JsonPath expression on a numeric array field.
Prompt 5
How do I use JsonPath to do a deep scan and find all fields matching a specific key name anywhere in a JSON document?
Open on GitHub → Explain another repo

← json-path on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.