object Json
source · line 13public object Json
JSON encoding and decoding through the ordinary ValueEncoder and ValueDecoder protocols.
Use the explicit codec overloads for custom representations, or the companion overloads when the type provides a codec. Malformed input and incompatible values report their path through DecodingException or EncodingException.
function objectDecoder
source · line 86public fun <V> objectDecoder(): ValueDecoder<LinkedHashMap<String, V>> where V.Companion : ValueDecoder<V>
Builds an object decoder using the value companion.
type parameter V
source · line 86V
function encodeToValue
source · line 60public fun <T> encodeToValue(value: T, codec: ValueEncoder<T>): JsonValue
Runs the codec into a JSON value tree that can be embedded in another JSON document without converting through text.
type parameter T
source · line 60T
parameter value
source · line 60value: T
parameter codec
source · line 60codec: ValueEncoder<T>
function decodeFromString
source · line 45public fun <T> decodeFromString(text: String, codec: ValueDecoder<T>): T
Parses one complete JSON document and decodes it using the selected codec. Invalid syntax, trailing input, and a value incompatible with the codec fail with DecodingException.
type parameter T
source · line 45T
parameter text
source · line 45text: String
parameter codec
source · line 45codec: ValueDecoder<T>
function objectEncoder
source · line 82public fun <V> objectEncoder(): ValueEncoder<Map<String, V>> where V.Companion : ValueEncoder<V>
Builds an object encoder using the value companion.
type parameter V
source · line 82V
function decodeFromValue
source · line 70public fun <T> decodeFromValue(value: JsonValue, codec: ValueDecoder<T>): T
Decodes an existing JSON value tree using the supplied codec, preserving path information in decoding errors.
type parameter T
source · line 70T
parameter value
source · line 70value: JsonValue
parameter codec
source · line 70codec: ValueDecoder<T>
function encodeToString
source · line 24public fun <T> encodeToString(value: T): String where T.Companion : ValueEncoder<T>
Encodes one value as a complete JSON document. The companion overload requires the type companion to implement ValueEncoder; the explicit overload uses the supplied codec.
parameter value
source · line 24value: T
type parameter T
source · line 24T
function decodeFromValue
source · line 53public fun <T> decodeFromValue(value: JsonValue): T where T.Companion : ValueDecoder<T>
Decodes a value tree as a new root using the requested type's companion codec.
type parameter T
source · line 53T
parameter value
source · line 53value: JsonValue
function stringify
source · line 18public fun stringify(value: JsonValue): String
Renders an existing value tree directly, preserving number tokens and member order.
parameter value
source · line 18value: JsonValue
function encodeToValue
source · line 49public fun <T> encodeToValue(value: T): JsonValue where T.Companion : ValueEncoder<T>
Encodes a value tree using the value's companion codec.
parameter value
source · line 49value: T
type parameter T
source · line 49T
function encodeToString
source · line 38public fun <T> encodeToString(value: T, codec: ValueEncoder<T>): String
Encodes one value as a complete JSON document. The companion overload requires the type companion to implement ValueEncoder; the explicit overload uses the supplied codec.
parameter codec
source · line 38codec: ValueEncoder<T>
parameter value
source · line 38value: T
type parameter T
source · line 38T
function decodeFromString
source · line 31public fun <T> decodeFromString(text: String): T where T.Companion : ValueDecoder<T>
Parses one complete JSON document and decodes it using the selected codec. Invalid syntax, trailing input, and a value incompatible with the codec fail with DecodingException.
type parameter T
source · line 31T
parameter text
source · line 31text: String
function parse
source · line 15public fun parse(text: String): JsonValue
Parses one complete, strict JSON document into an immutable value tree.
parameter text
source · line 15text: String
function objectDecoder
source · line 78public fun <V> objectDecoder(codec: ValueDecoder<V>): ValueDecoder<LinkedHashMap<String, V>>
Decodes JSON objects into independent insertion-ordered maps, using an explicit value codec.
parameter codec
source · line 78codec: ValueDecoder<V>
type parameter V
source · line 78V
function objectEncoder
source · line 74public fun <V> objectEncoder(codec: ValueEncoder<V>): ValueEncoder<Map<String, V>>
Encodes String-key maps as JSON objects in map iteration order, using an explicit value codec.
parameter codec
source · line 74codec: ValueEncoder<V>
type parameter V
source · line 74V