Target filter
Search Kotlin docs
  • Platforms
  • Tealium Prism Kotlin
core/com.tealium.prism.core.api.data/JsonPath

JsonPath

class JsonPath<TRoot : JsonPath.Component> : DataItemConvertible

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)
Content copied to clipboard

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"]
Content copied to clipboard

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]
Content copied to clipboard

Types

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

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

Converter
Link copied to clipboard
object Converter : DataItemConverter<JsonPath<*>>

DataItemConverter to create JsonPath instances from their String representations.

Properties

components
Link copied to clipboard
val components: List<JsonPath.Component>
firstComponent
Link copied to clipboard
val firstComponent: TRoot

Functions

asDataItem
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:

asListPathOrNull
Link copied to clipboard
fun JsonPath<*>.asListPathOrNull(): JsonPath<JsonPath.Component.Index>?

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

asObjectPathOrNull
Link copied to clipboard
fun JsonPath<*>.asObjectPathOrNull(): JsonPath<JsonPath.Component.Key>?

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

equals
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
get
Link copied to clipboard
operator fun <TRoot : JsonPath.Component> JsonPath<TRoot>.get(index: Int): JsonPath<TRoot>
operator fun <TRoot : JsonPath.Component> JsonPath<TRoot>.get(name: String): JsonPath<TRoot>

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

hashCode
Link copied to clipboard
open override fun hashCode(): Int
index
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.

key
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.

requireListPath
Link copied to clipboard
fun JsonPath<*>.requireListPath(): JsonPath<JsonPath.Component.Index>

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

requireObjectPath
Link copied to clipboard
fun JsonPath<*>.requireObjectPath(): JsonPath<JsonPath.Component.Key>

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

toString
Link copied to clipboard
open override fun toString(): String
Generated by Dokka
(c) Tealium 2026