api

http4k / org.http4k.format / Json

Json

interface Json<NODE>

This is the contract for all JSON implementations

Functions

Name Summary
array open fun <T : NODE> array(value: T): NODE
open fun <T : NODE> array(value: Iterable<T>): NODE
asCompactJsonString abstract fun NODE.asCompactJsonString(): String
asJsonArray abstract fun <T : Iterable<NODE>> T.asJsonArray(): NODE
asJsonObject abstract fun String.asJsonObject(): NODE
abstract fun <LIST : Iterable<Pair<String, NODE>>> LIST.asJsonObject(): NODE
asJsonValue abstract fun String?.asJsonValue(): NODE
abstract fun Int?.asJsonValue(): NODE
abstract fun Double?.asJsonValue(): NODE
abstract fun Long?.asJsonValue(): NODE
abstract fun BigDecimal?.asJsonValue(): NODE
abstract fun BigInteger?.asJsonValue(): NODE
abstract fun Boolean?.asJsonValue(): NODE
asPrettyJsonString abstract fun NODE.asPrettyJsonString(): String
body open fun body(description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<NODE>
bool abstract fun bool(value: NODE): Boolean
boolean open fun boolean(value: Boolean): NODE
compact open fun compact(node: NODE): String
compactify open fun compactify(input: String): String
decimal abstract fun decimal(value: NODE): BigDecimal
elements abstract fun elements(value: NODE): Iterable<NODE>
fields abstract fun fields(node: NODE): Iterable<Pair<String, NODE>>
integer abstract fun integer(value: NODE): Long
invoke open operator fun <T> invoke(fn: Json<NODE>.() -> T): T
json open fun <IN : Any> BiDiLensSpec<IN, String>.json(): BiDiLensSpec<IN, NODE>
lens open fun <IN : Any> lens(spec: BiDiLensSpec<IN, String>): BiDiLensSpec<IN, NODE>
nullNode open fun nullNode(): NODE
number open fun number(value: Int): NODE
open fun number(value: Double): NODE
open fun number(value: Long): NODE
open fun number(value: BigDecimal): NODE
open fun number(value: BigInteger): NODE
obj open fun obj(): NODE
open fun <T : NODE> obj(value: Iterable<Pair<String, T>>): NODE
open fun <T : NODE> obj(vararg fields: Pair<String, T>): NODE
parse open fun parse(input: String): NODE
prettify open fun prettify(input: String): String
pretty open fun pretty(node: NODE): String
string open fun string(value: String): NODE
text abstract fun text(value: NODE): String
textValueOf abstract fun textValueOf(node: NODE, name: String): String?
typeOf abstract fun typeOf(value: NODE): JsonType

Companion Object Functions

Name Summary
json open fun Body.Companion.json(description: String? = null, contentNegotiation: ContentNegotiation = None): BiDiBodyLensSpec<NODE>
open fun WsMessage.Companion.json(): BiDiWsMessageLensSpec<NODE>

Extension Functions

Name Summary
hasBody fun <NODE> Json<NODE>.hasBody(expected: NODE): Matcher<HttpMessage>
fun <NODE> Json<NODE>.hasBody(expected: Matcher<NODE>): Matcher<HttpMessage>
fun <NODE> Json<NODE>.hasBody(expected: String): Matcher<HttpMessage>
haveBody fun <NODE> Json<NODE>.haveBody(expected: NODE): Matcher<HttpMessage>
fun <NODE> Json<NODE>.haveBody(expected: Matcher<NODE>): Matcher<HttpMessage>
fun <NODE> Json<NODE>.haveBody(expected: String): Matcher<HttpMessage>

Inheritors

Name Summary
Argo object Argo : Json<JsonNode>
AutoMarshallingJson abstract class AutoMarshallingJson<NODE : Any> : AutoMarshalling, Json<NODE>