BufferedSourceJsonReader

class BufferedSourceJsonReader(source: BufferedSource) : JsonReader

A JsonWriter that reads json from an okio BufferedSource

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

To read from a Map, see also MapJsonReader

Constructors

Link copied to clipboard
fun BufferedSourceJsonReader(source: BufferedSource)

Types

Link copied to clipboard
object Companion

Functions

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

Consumes the next token from the JSON stream and asserts that it is the beginning of a new array.

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

Consumes the next token from the JSON stream and asserts that it is the beginning of a new object.

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

Consumes the next token from the JSON stream and asserts that it is the end of the current array.

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

Consumes the next token from the JSON stream and asserts that it is the end of the current object.

Link copied to clipboard
open override fun getPath(): List<Any>

Returns the current path of the JSON being read, as a List. The elements can either be Strings (names) or Integers (array indices).

Link copied to clipboard
open override fun hasNext(): Boolean

Returns true if the current array or object has another element.

Link copied to clipboard
open override fun nextBoolean(): Boolean

Returns the Token.BOOLEAN value of the next token, consuming it.

Link copied to clipboard
open override fun nextDouble(): Double

Returns the Token.NUMBER value of the next token, consuming it.

Link copied to clipboard
open override fun nextInt(): Int

Returns the Token.NUMBER value of the next token, consuming it.

Link copied to clipboard
open override fun nextLong(): Long

Returns the Token.NUMBER value of the next token, consuming it.

Link copied to clipboard
open override fun nextName(): String

Returns the next token Token.NAME, and consumes it.

Link copied to clipboard
open override fun nextNull(): Nothing?

Consumes the next token from the JSON stream and asserts that it is a literal null. Returns null.

Link copied to clipboard
open override fun nextNumber(): JsonNumber

Returns the Token.NUMBER value of the next token, consuming it.

Link copied to clipboard
open override fun nextString(): String?

Returns the Token.STRING value of the next token, consuming it.

Link copied to clipboard
open override fun peek(): JsonReader.Token

Returns the type of the next token without consuming it.

Link copied to clipboard
open override fun rewind()

Reset the current object so that selectName start returning names again

Link copied to clipboard
open override fun selectName(names: List<String>): Int

An optimized way to retrieve the nextName when the candidates and their order is known. selectName maintains the current index in the list and saves having to string compare nextName to every candidate.

Link copied to clipboard
open override fun skipValue()

Skips the next value recursively. If it is an object or array, all nested elements are skipped.