public abstract class JsonAdapter<T> extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
JsonAdapter.Factory |
| Constructor and Description |
|---|
JsonAdapter() |
| Modifier and Type | Method and Description |
|---|---|
JsonAdapter<T> |
failOnUnknown()
Returns a JSON adapter equal to this, but that throws a
JsonDataException when
unknown values are encountered. |
T |
fromJson(okio.BufferedSource source) |
abstract T |
fromJson(JsonReader reader) |
T |
fromJson(String string) |
T |
fromJsonValue(Object value)
Decodes a Java value object from
value, which must be comprised of maps, lists,
strings, numbers, booleans and nulls. |
JsonAdapter<T> |
indent(String indent)
Return a JSON adapter equal to this, but using
indent to control how the result is
formatted. |
JsonAdapter<T> |
lenient()
Returns a JSON adapter equal to this, but is lenient when reading and writing.
|
JsonAdapter<T> |
nullSafe()
Returns a JSON adapter equal to this JSON adapter, but with support for reading and writing
nulls.
|
JsonAdapter<T> |
serializeNulls()
Returns a JSON adapter equal to this JSON adapter, but that serializes nulls when encoding
JSON.
|
void |
toJson(okio.BufferedSink sink,
T value) |
abstract void |
toJson(JsonWriter writer,
T value) |
String |
toJson(T value) |
Object |
toJsonValue(T value)
Encodes
value as a Java value object comprised of maps, lists, strings, numbers,
booleans, and nulls. |
public abstract T fromJson(JsonReader reader) throws IOException
IOExceptionpublic final T fromJson(okio.BufferedSource source) throws IOException
IOExceptionpublic final T fromJson(String string) throws IOException
IOExceptionpublic abstract void toJson(JsonWriter writer, T value) throws IOException
IOExceptionpublic final void toJson(okio.BufferedSink sink,
T value)
throws IOException
IOExceptionpublic final Object toJsonValue(T value)
value as a Java value object comprised of maps, lists, strings, numbers,
booleans, and nulls.
Values encoded using value(double) or value(long) are modeled with the
corresponding boxed type. Values encoded using value(Number) are modeled as a
Long 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.
public final T fromJsonValue(Object value)
value, which must be comprised of maps, lists,
strings, numbers, booleans and nulls.public final JsonAdapter<T> serializeNulls()
public final JsonAdapter<T> nullSafe()
public final JsonAdapter<T> lenient()
public final JsonAdapter<T> failOnUnknown()
JsonDataException when
unknown values are encountered. This
constraint applies to both the top-level message handled by this type adapter as well as to
nested messages.public JsonAdapter<T> indent(String indent)
indent to control how the result is
formatted. The indent string to be repeated for each level of indentation in the
encoded document. If indent.isEmpty() the encoded document will be compact. Otherwise
the encoded document will be more human-readable.indent - a string containing only whitespace.Copyright © 2017. All Rights Reserved.