MapJsonWriter

A JsonWriter that writes data to a Map

Call beginObject, name, value, etc... like for regular Json writing. Once you're done, get the result in root

The returned Map will contain values of the following types:

  • String

  • Int

  • Double

  • Long

  • JsonNumber

  • null

  • Map where values are any of these values recursively

  • List where values are any of these values recursively

To write to a okio.BufferedSink, see also BufferedSinkJsonWriter

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val path: String

Functions

Link copied to clipboard
open override fun beginArray(): JsonWriter

Begins encoding a new array. Each call to this method must be paired with a call to endArray.

Link copied to clipboard
open override fun beginObject(): JsonWriter

Begins encoding a new object. Each call to this method must be paired with a call to endObject.

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun endArray(): JsonWriter

Ends encoding the current array.

Link copied to clipboard
open override fun endObject(): JsonWriter

Ends encoding the current object.

Link copied to clipboard
open override fun flush()

Flushes the writer

Link copied to clipboard
open override fun name(name: String): JsonWriter

Encodes the property name.

Link copied to clipboard
open override fun nullValue(): MapJsonWriter

Encodes null.

Link copied to clipboard
fun root(): Any?

Return the resulting representation of the Json as a Kotlin type. Most of the times, it will be a Map but MapJsonWriter also support writing lists and scalars at the root of the json

Link copied to clipboard
open override fun value(value: Upload): MapJsonWriter

Encodes a Upload.

open override fun value(value: JsonNumber): MapJsonWriter

Encodes number value.

fun value(value: Any?): MapJsonWriter

open override fun value(value: Boolean): MapJsonWriter

Encodes boolean value.

open override fun value(value: Double): MapJsonWriter

Encodes a finite double value.

open override fun value(value: Int): MapJsonWriter

Encodes int value.

open override fun value(value: Long): MapJsonWriter

Encodes long value.

open override fun value(value: String): MapJsonWriter

Encodes the literal string value, or null to encode a null literal.

Link copied to clipboard
fun JsonWriter.writeAny(value: Any?)
Link copied to clipboard
inline fun JsonWriter.writeArray(crossinline block: JsonWriter.() -> Unit)
Link copied to clipboard
inline fun JsonWriter.writeObject(crossinline block: JsonWriter.() -> Unit)