api

http4k / org.http4k.format / ConfigurableGson

ConfigurableGson

open class ConfigurableGson : AutoMarshallingJson<JsonElement>

Constructors

Name Summary
<init> ConfigurableGson(builder: GsonBuilder, defaultContentType: ContentType = APPLICATION_JSON)

Properties

Name Summary
defaultContentType val defaultContentType: ContentType
mapper val mapper: Gson

Functions

Name Summary
asA open fun <T : Any> asA(input: String, target: KClass<T>): T
open fun <T : Any> asA(j: JsonElement, target: KClass<T>): T
fun <T : Any> JsonElement.asA(): T
asCompactJsonString open fun JsonElement.asCompactJsonString(): String
asJsonArray open fun <T : Iterable<JsonElement>> T.asJsonArray(): JsonElement
asJsonObject open fun String.asJsonObject(): JsonElement
open fun <LIST : Iterable<Pair<String, JsonElement>>> LIST.asJsonObject(): JsonObject
open fun asJsonObject(input: Any): JsonElement
asJsonValue open fun String?.asJsonValue(): JsonElement
open fun Int?.asJsonValue(): JsonElement
open fun Double?.asJsonValue(): JsonElement
open fun Long?.asJsonValue(): JsonElement
open fun BigDecimal?.asJsonValue(): JsonElement
open fun BigInteger?.asJsonValue(): JsonElement
open fun Boolean?.asJsonValue(): JsonElement
asPrettyJsonString open fun JsonElement.asPrettyJsonString(): String
autoBody fun <T : Any> autoBody(description: String? = null, contentNegotiation: ContentNegotiation = None, contentType: ContentType = defaultContentType): <ERROR CLASS>
bool open fun bool(value: JsonElement): Boolean
decimal open fun decimal(value: JsonElement): BigDecimal
elements open fun elements(value: JsonElement): Iterable<JsonElement>
fields open fun fields(node: JsonElement): Iterable<Pair<String, JsonElement>>
integer open fun integer(value: JsonElement): Long
text open fun text(value: JsonElement): String
textValueOf open fun textValueOf(node: JsonElement, name: String): String
typeOf open fun typeOf(value: JsonElement): JsonType

Companion Object Functions

Name Summary
auto fun <T : Any> WsMessage.Companion.auto(): BiDiWsMessageLensSpec<T>
fun <T : Any> Body.Companion.auto(description: String? = null, contentNegotiation: ContentNegotiation = None, contentType: ContentType = defaultContentType): <ERROR CLASS>

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
Gson To implement custom JSON configuration, create your own object singleton. Extra mappings can be added before done() is called.object Gson : ConfigurableGson