SingleJsonPathBuilder

class SingleJsonPathBuilder(initialPath: String = "")

Builder for generating a JSON path expression to a single JSON subtree or child.

Note that this class is a very rudimentary builder. There are a lot more restrictions when using this class, including:

  • initialPath of the constructor must either by empty or starts with '$'.

  • All child elements are appended using the dot syntax (.child).

  • All array indices are appended using the array subscript syntax ([]).

On the other hand, this class will not attempt to verify the correctness of the JSON Path expression.

It is recommended to provide no arguments to the constructor if trying to build a new JSON Path. Passing a string to the constructor is only recommended if you need to append to an existing JSON Path.

Throws

if initialPath does not start with $.

Constructors

Link copied to clipboard
constructor(initialPath: String = "")

Properties

Link copied to clipboard
private val sb: StringBuilder

Functions

Link copied to clipboard

Appends an array index to the JSON path.

Link copied to clipboard

Appends a child element to the JSON path.

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