BufferedSinkJsonWriter

class BufferedSinkJsonWriter @JvmOverloads() constructor(sink: BufferedSink, indent: String?) : 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

BufferedSinkJsonWriter
Link copied to clipboard
common
fun BufferedSinkJsonWriter(sink: BufferedSink, indent: String? = null)
: A string containing a full set of spaces for a single level of indentation, or null for no pretty printing.

Types

Companion
Link copied to clipboard
common
object Companion

Functions

beginArray
Link copied to clipboard
common
open override fun beginArray(): JsonWriter
Begins encoding a new array.
beginObject
Link copied to clipboard
common
open override fun beginObject(): JsonWriter
Begins encoding a new object.
close
Link copied to clipboard
common
open override fun close()
Flushes and closes this writer and the underlying okio.Sink.
endArray
Link copied to clipboard
common
open override fun endArray(): JsonWriter
Ends encoding the current array.
endObject
Link copied to clipboard
common
open override fun endObject(): JsonWriter
Ends encoding the current object.
flush
Link copied to clipboard
common
open override fun flush()
Ensures all buffered data is written to the underlying okio.Sink and flushes that writer.
jsonValue
Link copied to clipboard
common
fun jsonValue(value: String): JsonWriter
Writes the given value as raw json without escaping.
name
Link copied to clipboard
common
open override fun name(name: String): JsonWriter
Encodes the property name.
nullValue
Link copied to clipboard
common
open override fun nullValue(): JsonWriter
Encodes null.
value
Link copied to clipboard
common
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.

Properties

path
Link copied to clipboard
common
open override val path: String
Returns a JsonPath to the current location in the JSON value.