BufferedSinkJsonWriter

class BufferedSinkJsonWriter @JvmOverloads constructor(sink: BufferedSink, indent: String? = null) : JsonWriter

A JsonWriter that writes json to an okio BufferedSink

The base implementation was taken from Moshi and ported to Kotlin multiplatform with some tweaks to make it better suited for GraphQL (see JsonWriter and path).

To writer to a Map, see also MapJsonWriter

Parameters

indent

: A string containing a full set of spaces for a single level of indentation, or null for no pretty printing.

Constructors

Link copied to clipboard
constructor(sink: BufferedSink, indent: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val path: String

Returns a JsonPath to the current location in the JSON value.

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()

Flushes and closes this writer and the underlying okio.Sink.

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()

Ensures all buffered data is written to the underlying okio.Sink and flushes that writer.

Link copied to clipboard

Writes the given value as raw json without escaping. It is the caller responsibility to make sure value is a valid json string

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

Encodes the property name.

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

Encodes null.

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

Encodes a Upload.

open override fun value(value: JsonNumber): JsonWriter

Encodes number value.

open override fun value(value: Boolean): JsonWriter

Encodes boolean value.

open override fun value(value: Double): JsonWriter

Encodes a finite double value.

open override fun value(value: Int): JsonWriter

Encodes int value.

open override fun value(value: Long): JsonWriter

Encodes long value.

open override fun value(value: String): JsonWriter

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)