Strikt.jackson

package strikt.jackson

Methods

has

infix fun <T> Assertion.Builder<T>.has(fieldName: String): Assertion.Builder<T>

Asserts that the subject node has a field named fieldName.

Receiver

Name Description
Assertion.Builder<T>

Parameters

Name Description
fieldName: String

ReturnValue

Name Description
Assertion.Builder<T>

path

infix fun <T> Assertion.Builder<T>.path(fieldName: String): Assertion.Builder<JsonNode>

Maps the subject node of the assertion builder to the node accessed by fieldName.

Receiver

Name Description
Assertion.Builder<T>

Parameters

Name Description
fieldName: String

ReturnValue

Name Description
Assertion.Builder<JsonNode>

an assertion builder whose subject is the named field. If the path is invalid the subject of the returned assertion builder will be a com.fasterxml.jackson.databind.node.MissingNode.

at

infix fun <T> Assertion.Builder<T>.at(pointer: String): Assertion.Builder<JsonNode>

Maps the subject node of the assertion builder to the node accessed by pointer.

Receiver

Name Description
Assertion.Builder<T>

Parameters

Name Description
pointer: String

ReturnValue

Name Description
Assertion.Builder<JsonNode>

an assertion builder whose subject is the node at pointer. If pointer is invalid the subject of the returned assertion builder will be a com.fasterxml.jackson.databind.node.MissingNode.

at

infix fun <T> Assertion.Builder<T>.at(pointer: JsonPointer): Assertion.Builder<JsonNode>

Maps the subject node of the assertion builder to the node accessed by pointer.

Receiver

Name Description
Assertion.Builder<T>

Parameters

Name Description
pointer: JsonPointer

ReturnValue

Name Description
Assertion.Builder<JsonNode>

an assertion builder whose subject is the node at pointer. If pointer is invalid the subject of the returned assertion builder will be a com.fasterxml.jackson.databind.node.MissingNode.

isObject

fun <T> Assertion.Builder<T>.isObject(): Assertion.Builder<ObjectNode>

Asserts that the subject node is a JSON object.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<ObjectNode>

an assertion builder over the same subject that is now known to be an ObjectNode.

isArray

fun <T> Assertion.Builder<T>.isArray(): Assertion.Builder<ArrayNode>

Asserts that the subject node is a JSON array.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<ArrayNode>

an assertion builder over the same subject that is now known to be an ArrayNode.

isTextual

fun <T> Assertion.Builder<T>.isTextual(): Assertion.Builder<TextNode>

Asserts that the subject node is a JSON text node.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<TextNode>

an assertion builder over the same subject that is now known to be a TextNode.

isNumber

fun <T> Assertion.Builder<T>.isNumber(): Assertion.Builder<NumericNode>

Asserts that the subject node is a JSON numeric node.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<NumericNode>

an assertion builder over the same subject that is now known to be a NumericNode.

isBoolean

fun <T> Assertion.Builder<T>.isBoolean(): Assertion.Builder<BooleanNode>

Asserts that the subject node is a JSON boolean node.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<BooleanNode>

an assertion builder over the same subject that is now known to be a BooleanNode.

isMissing

fun <T> Assertion.Builder<T>.isMissing(): Assertion.Builder<MissingNode>

Asserts that the subject node is a JSON missing node.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<MissingNode>

an assertion builder over the same subject that is now known to be a MissingNode.

textValue

fun <T> Assertion.Builder<T>.textValue(): Assertion.Builder<String?>

Maps the assertion to an assertion on the subject node's text value.

Be aware that if the node is not a text node this will map to an assertion on null.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<String?>

numberValue

fun <T> Assertion.Builder<T>.numberValue(): Assertion.Builder<Number?>

Maps the assertion to an assertion on the subject node's number value.

Be aware that if the node is not a numeric node this will map to an assertion on null.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<Number?>

booleanValue

fun <T> Assertion.Builder<T>.booleanValue(): Assertion.Builder<Boolean>

Maps the assertion to an assertion on the subject node's boolean value.

Be aware that if the node is not a boolean node this will map to an assertion on false.

Receiver

Name Description
Assertion.Builder<T>

ReturnValue

Name Description
Assertion.Builder<Boolean>

hasNodeType

infix fun <T> Assertion.Builder<T>.hasNodeType(nodeType: JsonNodeType): Assertion.Builder<T>

Asserts that the subject node's JsonNode.getNodeType method returns nodeType.

Convenient aliases for this assertion exist for common node types that also narrow the subject type of the resulting assertion builder.

Receiver

Name Description
Assertion.Builder<T>

Parameters

Name Description
nodeType: JsonNodeType

ReturnValue

Name Description
Assertion.Builder<T>

hasSize

infix fun Assertion.Builder<ArrayNode>.hasSize(expected: Int): Assertion.Builder<ArrayNode>

Asserts that a JSON array's size is equal to expected.

Receiver

Name Description
Assertion.Builder<ArrayNode>

Parameters

Name Description
expected: Int

ReturnValue

Name Description
Assertion.Builder<ArrayNode>

size

fun Assertion.Builder<ArrayNode>.size(): Assertion.Builder<Int>

Maps an assertion on a JSON array to an assertion on its size.

Receiver

Name Description
Assertion.Builder<ArrayNode>

ReturnValue

Name Description
Assertion.Builder<Int>