public class DJsonContext extends Object implements JsonContext
Constructor and Description |
---|
DJsonContext(SpiEbeanServer server,
JsonValueAdapter dfltValueAdapter,
boolean dfltPretty) |
Modifier and Type | Method and Description |
---|---|
boolean |
isSupportedType(Type genericType)
Return true if the type is known as an Entity or Xml type or a List Set or
Map of known bean types.
|
<T> T |
toBean(Class<T> cls,
Reader jsonReader)
Convert json reader input into a Bean of a specific type.
|
<T> T |
toBean(Class<T> cls,
Reader jsonReader,
JsonReadOptions options)
Convert json reader input into a Bean of a specific type with options.
|
<T> T |
toBean(Class<T> cls,
String json)
Convert json string input into a Bean of a specific type.
|
<T> T |
toBean(Class<T> cls,
String json,
JsonReadOptions options)
Convert json string input into a Bean of a specific type with options.
|
String |
toJsonString(Object o)
Convert a bean or collection to json string using default options.
|
String |
toJsonString(Object o,
boolean pretty)
Convert a bean or collection to json string with pretty format using
default options.
|
String |
toJsonString(Object o,
boolean pretty,
JsonWriteOptions options)
Convert a bean or collection to json string using options.
|
String |
toJsonString(Object o,
boolean pretty,
JsonWriteOptions options,
String callback)
Convert a bean or collection to json string using a JSONP callback.
|
void |
toJsonWriter(Object o,
Writer writer)
Write the bean or collection in JSON format to the writer with default
options.
|
void |
toJsonWriter(Object o,
Writer writer,
boolean pretty)
With additional pretty output option.
|
void |
toJsonWriter(Object o,
Writer writer,
boolean pretty,
JsonWriteOptions options)
With additional options to specify JsonValueAdapter and
JsonWriteBeanVisitor's.
|
void |
toJsonWriter(Object o,
Writer writer,
boolean pretty,
JsonWriteOptions options,
String callback)
With additional JSONP callback function.
|
<T> List<T> |
toList(Class<T> cls,
Reader jsonReader)
Convert json reader input into a list of beans of a specific type.
|
<T> List<T> |
toList(Class<T> cls,
Reader jsonReader,
JsonReadOptions options)
Convert json reader input into a list of beans of a specific type with
options.
|
<T> List<T> |
toList(Class<T> cls,
String json)
Convert json string input into a list of beans of a specific type.
|
<T> List<T> |
toList(Class<T> cls,
String json,
JsonReadOptions options)
Convert json string input into a list of beans of a specific type with
options.
|
Object |
toObject(Type genericType,
Reader json,
JsonReadOptions options)
Use the genericType to determine if this should be converted into a List or
bean.
|
Object |
toObject(Type genericType,
String json,
JsonReadOptions options)
Use the genericType to determine if this should be converted into a List or
bean.
|
public DJsonContext(SpiEbeanServer server, JsonValueAdapter dfltValueAdapter, boolean dfltPretty)
public boolean isSupportedType(Type genericType)
JsonContext
isSupportedType
in interface JsonContext
public <T> T toBean(Class<T> cls, String json)
JsonContext
toBean
in interface JsonContext
public <T> T toBean(Class<T> cls, Reader jsonReader)
JsonContext
toBean
in interface JsonContext
public <T> T toBean(Class<T> cls, String json, JsonReadOptions options)
JsonContext
toBean
in interface JsonContext
public <T> T toBean(Class<T> cls, Reader jsonReader, JsonReadOptions options)
JsonContext
toBean
in interface JsonContext
public <T> List<T> toList(Class<T> cls, String json)
JsonContext
toList
in interface JsonContext
public <T> List<T> toList(Class<T> cls, String json, JsonReadOptions options)
JsonContext
toList
in interface JsonContext
public <T> List<T> toList(Class<T> cls, Reader jsonReader)
JsonContext
toList
in interface JsonContext
public <T> List<T> toList(Class<T> cls, Reader jsonReader, JsonReadOptions options)
JsonContext
toList
in interface JsonContext
public Object toObject(Type genericType, String json, JsonReadOptions options)
JsonContext
toObject
in interface JsonContext
public Object toObject(Type genericType, Reader json, JsonReadOptions options)
JsonContext
toObject
in interface JsonContext
public void toJsonWriter(Object o, Writer writer)
JsonContext
toJsonWriter
in interface JsonContext
o
- the bean or collection of beans to writewriter
- used to write the json output topublic void toJsonWriter(Object o, Writer writer, boolean pretty)
JsonContext
toJsonWriter
in interface JsonContext
public void toJsonWriter(Object o, Writer writer, boolean pretty, JsonWriteOptions options)
JsonContext
toJsonWriter
in interface JsonContext
o
- the bean or collection of beans to writewriter
- used to write the json output tooptions
- additional options to control the JSON outputpublic void toJsonWriter(Object o, Writer writer, boolean pretty, JsonWriteOptions options, String callback)
JsonContext
toJsonWriter
in interface JsonContext
public String toJsonString(Object o)
JsonContext
toJsonString
in interface JsonContext
public String toJsonString(Object o, boolean pretty)
JsonContext
toJsonString
in interface JsonContext
public String toJsonString(Object o, boolean pretty, JsonWriteOptions options)
JsonContext
toJsonString
in interface JsonContext
public String toJsonString(Object o, boolean pretty, JsonWriteOptions options, String callback)
JsonContext
toJsonString
in interface JsonContext
Copyright © 2015. All Rights Reserved.