Package-level declarations
JSON serialization format implementation, JSON tree data structures with builders for them, and JSON-specific serializers.
JSON serialization format implementation, JSON tree data structures with builders for them, and JSON-specific serializers.
JSON serialization format implementation, JSON tree data structures with builders for them, and JSON-specific serializers.
Types
Defines which classes and objects should have their serial name included in the json as so-called class discriminator.
Description of JSON input shape used for decoding to sequence.
The main entry point to work with JSON serialization. It is typically used by constructing an application-specific instance, with configured JSON-specific behaviour and, if necessary, registered in SerializersModule custom serializers. Json
instance can be configured in its Json {}
factory function using JsonBuilder. For demonstration purposes or trivial usages, Json companion can be used instead.
Class representing JSON array, consisting of indexed values, where value is arbitrary JsonElement
DSL builder for a JsonArray. To create an instance of builder, use buildJsonArray build function.
Builder of the Json instance provided by Json { ... }
factory function:
Specifies key for class discriminator value used during polymorphic serialization in Json. Provided key is used only for an annotated class and its subclasses; to configure global class discriminator, use JsonBuilder.classDiscriminator property.
Configuration of the current Json instance available through Json.configuration and configured with JsonBuilder constructor.
Base class for custom serializers that allows selecting polymorphic serializer without a dedicated class discriminator, on a content basis.
Class representing single JSON element. Can be JsonPrimitive, JsonArray or JsonObject.
Represents naming strategy — a transformer for serial names in a Json format. Transformed serial names are used for both serialization and deserialization. A naming strategy is always applied globally in the Json configuration builder (see JsonBuilder.namingStrategy).
Class representing JSON null
value
Class representing JSON object, consisting of name-value pairs, where value is arbitrary JsonElement
DSL builder for a JsonObject. To create an instance of builder, use buildJsonObject build function.
Class representing JSON primitive value. JSON primitives include numbers, strings, booleans and special null value JsonNull.
Base class for custom serializers that allows manipulating an abstract JSON representation of the class before serialization or deserialization.
Properties
Returns content of current element as boolean
Returns content of current element as boolean or null
if current element is not a valid representation of boolean
Content of the given element without quotes or null
if current element is JsonNull
Returns content of current element as double
Returns content of current element as double or null
if current element is not a valid representation of number
Returns content of current element as float
Returns content of current element as float or null
if current element is not a valid representation of number
Returns content of the current element as int
Returns content of the current element as int or null
if current element is not a valid representation of number
Convenience method to get current element as JsonArray
Convenience method to get current element as JsonNull
Convenience method to get current element as JsonObject
Convenience method to get current element as JsonPrimitive
Returns content of current element as long
Returns content of current element as long or null
if current element is not a valid representation of number
Functions
Adds the given boolean values to a resulting JSON array.
Adds the given numeric values to a resulting JSON array.
Adds the given string values to a resulting JSON array.
Adds the JSON array produced by the builderAction function to a resulting JSON array.
Adds the JSON object produced by the builderAction function to a resulting JSON array.
Builds JsonArray with the given builderAction builder. Example of usage:
Builds JsonObject with the given builderAction builder. Example of usage:
A reified version of decodeFromDynamic.
Converts native JavaScript objects into Kotlin ones, verifying their types.
Deserializes the contents of given stream to the value of type T using UTF-8 encoding and deserializer retrieved from the reified type parameter.
Deserializes JSON from stream using UTF-8 encoding to a value of type T using deserializer.
Transforms the given stream into lazily deserialized sequence of elements of type T using UTF-8 encoding and deserializer retrieved from the reified type parameter. Unlike decodeFromStream, stream is allowed to have more than one element, separated as format declares.
Transforms the given stream into lazily deserialized sequence of elements of type T using UTF-8 encoding and deserializer. Unlike decodeFromStream, stream is allowed to have more than one element, separated as format declares.
A reified version of encodeToDynamic.
Converts Kotlin data structures to plain Javascript objects
Serializes the given value into an equivalent JsonElement using a serializer retrieved from reified type parameter.
Serializes given value to stream using UTF-8 encoding and serializer retrieved from the reified type parameter.
Serializes the value with serializer into a stream using JSON format and UTF-8 encoding.
Creates an instance of Json configured from the optionally given Json instance and adjusted with builderAction.
Creates a JsonPrimitive from the given boolean.
Creates JsonNull.
Creates a JsonPrimitive from the given number.
Creates a JsonPrimitive from the given string.
Creates a numeric JsonPrimitive from the given UByte.
Creates a numeric JsonPrimitive from the given UInt.
Creates a numeric JsonPrimitive from the given ULong.
Creates a numeric JsonPrimitive from the given UShort.
Creates a JsonPrimitive from the given string, without surrounding it in quotes.
Add null
to a resulting JSON object using the given key.
Add the JSON array produced by the builderAction function to a resulting JSON object using the given key.
Add the JSON object produced by the builderAction function to a resulting JSON object using the given key.