EnumJsonAdapter

class EnumJsonAdapter<T : Enum<T>?> : JsonAdapter<T>

Constructors

EnumJsonAdapter
Link copied to clipboard
open fun EnumJsonAdapter(enumType: Class<T>)

Functions

failOnUnknown
Link copied to clipboard

Returns a JSON adapter equal to this, but that throws a JsonDataException when unknown names and values are encountered. This constraint applies to both the top-level message handled by this type adapter as well as to nested messages.

fun failOnUnknown(): JsonAdapter<T>
fromJson
Link copied to clipboard
fun fromJson(string: String): T
fun fromJson(source: BufferedSource): T
open fun fromJson(reader: JsonReader): T
fromJsonValue
Link copied to clipboard

Decodes a Java value object from {@code value} , which must be comprised of maps, lists, strings, numbers, booleans and nulls.

fun fromJsonValue(value: Any): T
indent
Link copied to clipboard

Return a JSON adapter equal to this, but using {@code indent} to control how the result is formatted. The {@code indent} string to be repeated for each level of indentation in the encoded document. If {@code indent.isEmpty()} the encoded document will be compact. Otherwise the encoded document will be more human-readable.

open fun indent(indent: String): JsonAdapter<T>
isLenient
Link copied to clipboard
open fun isLenient(): Boolean
lenient
Link copied to clipboard

Returns a JSON adapter equal to this, but is lenient when reading and writing.

fun lenient(): JsonAdapter<T>
nonNull
Link copied to clipboard

Returns a JSON adapter equal to this JSON adapter, but that refuses null values. If null is read or written this will throw a JsonDataException .

Note that this adapter will not usually be invoked for absent values and so those must be handled elsewhere. This should only be used to fail on explicit nulls.

fun nonNull(): JsonAdapter<T>
nullSafe
Link copied to clipboard

Returns a JSON adapter equal to this JSON adapter, but with support for reading and writing nulls.

fun nullSafe(): JsonAdapter<T>
serializeNulls
Link copied to clipboard

Returns a JSON adapter equal to this JSON adapter, but that serializes nulls when encoding JSON.

fun serializeNulls(): JsonAdapter<T>
toJson
Link copied to clipboard
fun toJson(value: T): String
abstract fun toJson(writer: JsonWriter, value: T)
fun toJson(sink: BufferedSink, value: T)
open fun toJson(writer: JsonWriter, value: T)
toJsonValue
Link copied to clipboard

Encodes {@code value} as a Java value object comprised of maps, lists, strings, numbers, booleans, and nulls.

Values encoded using {@code value(double)} or {@code value(long)} are modeled with the corresponding boxed type. Values encoded using {@code value(Number)} are modeled as a for boxed integer types ( Byte , Short , Integer , and Long ), as a Double for boxed floating point types ( Float and Double ), and as a BigDecimal for all other types.

fun toJsonValue(value: T): Any
toString
Link copied to clipboard
open fun toString(): String