JsonPath

A structure representing the location of an item in a JSON object or JSON array, potentially nested in other JSON objects and JSON arrays.

To create a basic JsonPath you can call the JsonPath factory methods JsonPath.key and JsonPath.index depending on where you want to start the path from: the first one would start from a JSON object, the second would start from a JSON array.

val objectPath = JsonPath.key("container")
val arrayPath = JsonPath.index(0)

To create a path like container.array[0].property you can use a subscript for each path component:

JsonPath.key("container")
.key("array")
.index(0)
.key("property")

// or for Kotlin users only
JsonPath["container"]["array"][0]["property"]

Kotlin users can make use of the more expressive syntax through the get operator functions for easy readability

val objectPath = JsonPath["container"]
val arrayPath = JsonPath[0]

Types

Link copied to clipboard
object Companion
Link copied to clipboard
sealed class Component

Defines a Component of a JsonPath for navigating through complex JSON objects/arrays

Link copied to clipboard

DataItemConverter to create JsonPath instances from their String representations.

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
open override fun asDataItem(): DataItem

Should return an instance of a DataItem that represents all required properties of the implementing class, such that it could be:

Link copied to clipboard

Utility method to cast a JsonPath of unknown type, e.g. from a JsonPath.parse to the required type.

Link copied to clipboard

Utility method to cast a JsonPath of unknown type, e.g. from a JsonPath.parse to the required type.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Kotlin convenience method to allow expressing JsonPath items in a more succinct way:

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun index(index: Int): JsonPath<TRoot>

Returns a new JsonPath with an additional Component.Index used to access an index in the next JSON array.

Link copied to clipboard
fun key(key: String): JsonPath<TRoot>

Returns a new JsonPath with an additional Component.Key used to access a key in the next JSON object.

Link copied to clipboard

Utility method to cast a JsonPath of unknown type, e.g. from a JsonPath.parse to the required type.

Link copied to clipboard

Utility method to cast a JsonPath of unknown type, e.g. from a JsonPath.parse to the required type.

Link copied to clipboard
open override fun toString(): String