Json5

sealed class Json5 : StringFormat(source)

Main interface to serialize a given object hierarchy to JSON5 or vice versa.

The default class implementing this interface is available as the companion object. It can be used as shown in the following example:

import io.github.xn32.json5k.Json5
import kotlinx.serialization.encodeToString

Json5.encodeToString(1000)

A custom instance is obtained by calling the builder function and populating the associated ConfigBuilder object with the desired configuration options.

Inheritors

Types

Link copied to clipboard
object Default : Json5

This companion object is the default implementation of the Json5 interface.

Functions

Link copied to clipboard
inline fun <T> Json5.decodeFromStream(inputStream: InputStream): T

Convenience function that calls Json5.decodeFromStream with the default serializer for the type.

fun <T> Json5.decodeFromStream(deserializer: DeserializationStrategy<T>, inputStream: InputStream): T

Deserializes the JSON5 input from inputStream using the given deserializer and returns an equivalent object hierarchy.

Link copied to clipboard
open override fun <T> decodeFromString(deserializer: DeserializationStrategy<T>, string: String): T

Deserializes the JSON5 input in string using the given deserializer and returns an equivalent object hierarchy.

Link copied to clipboard
inline fun <T> Json5.encodeToStream(value: T, outputStream: OutputStream)

Convenience function that calls Json5.encodeToStream with the default serializer for the type.

fun <T> Json5.encodeToStream(serializer: SerializationStrategy<T>, value: T, outputStream: OutputStream)

Serializes the given value using the given serializer and writes the result to outputStream.

Link copied to clipboard
open override fun <T> encodeToString(serializer: SerializationStrategy<T>, value: T): String

Serializes the given value using the provided serializer and returns the value as a string.

Properties

Link copied to clipboard