Using JSONPath in your Java application

There's an implementation of JSONPath for Java, too, written by Jayway. It's available from GitHub, or you can obtain it through the Central Maven Repository if your project uses the Maven build system. It matches the original JSONPath API, returning Java objects and collections for fields in JSON objects.

Getting ready

You'll need to either download the code from GitHub at https://github.com/jayway/JsonPath, or, if you're using Maven as your build system, include the following dependency:

<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.0.0</version>
</dependency>

How to do it…

The Java implementation parses your JSON and exports a JsonPath class with a method ...

Get JavaScript JSON Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.