public class Json extends Object
| Constructor and Description |
|---|
Json() |
Json(OutputType outputType) |
| Modifier and Type | Method and Description |
|---|---|
void |
addClassTag(String tag,
Class type) |
<T> T |
fromJson(Class<T> type,
char[] data,
int offset,
int length) |
<T> T |
fromJson(Class<T> type,
Class elementType,
char[] data,
int offset,
int length) |
<T> T |
fromJson(Class<T> type,
Class elementType,
File file) |
<T> T |
fromJson(Class<T> type,
Class elementType,
InputStream input) |
<T> T |
fromJson(Class<T> type,
Class elementType,
Reader reader) |
<T> T |
fromJson(Class<T> type,
Class elementType,
String json) |
<T> T |
fromJson(Class<T> type,
File file) |
<T> T |
fromJson(Class<T> type,
InputStream input) |
<T> T |
fromJson(Class<T> type,
Reader reader) |
<T> T |
fromJson(Class<T> type,
String json) |
Class |
getClass(String tag) |
<T> JsonSerializer<T> |
getSerializer(Class<T> type) |
String |
getTag(Class type) |
JsonWriter |
getWriter() |
protected Object |
newInstance(Class type) |
String |
prettyPrint(Object object) |
String |
prettyPrint(Object object,
int singleLineColumns) |
String |
prettyPrint(Object object,
JsonValue.PrettyPrintSettings settings) |
String |
prettyPrint(String json) |
String |
prettyPrint(String json,
int singleLineColumns) |
String |
prettyPrint(String json,
JsonValue.PrettyPrintSettings settings) |
void |
readField(Object object,
String name,
Class elementType,
JsonValue jsonData) |
void |
readField(Object object,
String name,
JsonValue jsonData) |
void |
readField(Object object,
String fieldName,
String jsonName,
Class elementType,
JsonValue jsonMap) |
void |
readField(Object object,
String fieldName,
String jsonName,
JsonValue jsonData) |
void |
readFields(Object object,
JsonValue jsonMap) |
<T> T |
readValue(Class<T> type,
Class elementType,
JsonValue jsonData) |
<T> T |
readValue(Class<T> type,
Class elementType,
T defaultValue,
JsonValue jsonData) |
<T> T |
readValue(Class<T> type,
JsonValue jsonData) |
<T> T |
readValue(String name,
Class<T> type,
Class elementType,
JsonValue jsonMap) |
<T> T |
readValue(String name,
Class<T> type,
Class elementType,
T defaultValue,
JsonValue jsonMap) |
<T> T |
readValue(String name,
Class<T> type,
JsonValue jsonMap) |
<T> T |
readValue(String name,
Class<T> type,
T defaultValue,
JsonValue jsonMap) |
void |
setDefaultSerializer(JsonSerializer defaultSerializer) |
void |
setElementType(Class type,
String fieldName,
Class elementType) |
void |
setIgnoreUnknownFields(boolean ignoreUnknownFields) |
void |
setOutputType(OutputType outputType) |
<T> void |
setSerializer(Class<T> type,
JsonSerializer<T> serializer) |
void |
setTypeName(String typeName)
Sets the name of the JSON field to store the Java class name or class tag when required to avoid ambiguity during
deserialization.
|
void |
setUsePrototypes(boolean usePrototypes) |
void |
setWriter(Writer writer)
Sets the writer where JSON output will go.
|
String |
toJson(Object object) |
String |
toJson(Object object,
Class knownType) |
String |
toJson(Object object,
Class knownType,
Class elementType) |
void |
toJson(Object object,
Class knownType,
Class elementType,
File file) |
void |
toJson(Object object,
Class knownType,
Class elementType,
Writer writer) |
void |
toJson(Object object,
Class knownType,
File file) |
void |
toJson(Object object,
Class knownType,
Writer writer) |
void |
toJson(Object object,
File file) |
void |
toJson(Object object,
Writer writer) |
void |
writeArrayEnd() |
void |
writeArrayStart() |
void |
writeArrayStart(String name) |
void |
writeField(Object object,
String name) |
void |
writeField(Object object,
String name,
Class elementType) |
void |
writeField(Object object,
String fieldName,
String jsonName) |
void |
writeField(Object object,
String fieldName,
String jsonName,
Class elementType)
Writes the specified field to the current JSON object.
|
void |
writeFields(Object object)
Writes all fields of the specified object to the current JSON object.
|
void |
writeObjectEnd() |
void |
writeObjectStart() |
void |
writeObjectStart(Class actualType,
Class knownType)
Starts writing an object, writing the actualType to a field if needed.
|
void |
writeObjectStart(String name) |
void |
writeObjectStart(String name,
Class actualType,
Class knownType) |
void |
writeType(Class type) |
void |
writeValue(Object value)
Writes the value, without writing the class of the object.
|
void |
writeValue(Object value,
Class knownType)
Writes the value, writing the class of the object if it differs from the specified known type.
|
void |
writeValue(Object value,
Class knownType,
Class elementType)
Writes the value, writing the class of the object if it differs from the specified known type.
|
void |
writeValue(String name,
Object value)
Writes the value as a field on the current JSON object, without writing the actual class.
|
void |
writeValue(String name,
Object value,
Class knownType)
Writes the value as a field on the current JSON object, writing the class of the object if it differs from the specified
known type.
|
void |
writeValue(String name,
Object value,
Class knownType,
Class elementType)
Writes the value as a field on the current JSON object, writing the class of the object if it differs from the specified
known type.
|
public Json()
public Json(OutputType outputType)
public void setIgnoreUnknownFields(boolean ignoreUnknownFields)
public void setOutputType(OutputType outputType)
public void setTypeName(String typeName)
public void setDefaultSerializer(JsonSerializer defaultSerializer)
public <T> void setSerializer(Class<T> type, JsonSerializer<T> serializer)
public <T> JsonSerializer<T> getSerializer(Class<T> type)
public void setUsePrototypes(boolean usePrototypes)
public String toJson(Object object, Class knownType, Class elementType)
knownType - May be null if the type is unknown.elementType - May be null if the type is unknown.public void toJson(Object object, Class knownType, File file)
knownType - May be null if the type is unknown.public void toJson(Object object, Class knownType, Class elementType, File file)
knownType - May be null if the type is unknown.elementType - May be null if the type is unknown.public void toJson(Object object, Class knownType, Writer writer)
knownType - May be null if the type is unknown.public void toJson(Object object, Class knownType, Class elementType, Writer writer)
knownType - May be null if the type is unknown.elementType - May be null if the type is unknown.public void setWriter(Writer writer)
public JsonWriter getWriter()
public void writeFields(Object object)
public void writeField(Object object, String name, Class elementType)
elementType - May be null if the type is unknown.writeField(Object, String, String, Class)public void writeField(Object object, String fieldName, String jsonName, Class elementType)
elementType - May be null if the type is unknown.public void writeValue(String name, Object value)
value - May be null.writeValue(String, Object, Class, Class)public void writeValue(String name, Object value, Class knownType)
value - May be null.knownType - May be null if the type is unknown.writeValue(String, Object, Class, Class)public void writeValue(String name, Object value, Class knownType, Class elementType)
value - May be null.knownType - May be null if the type is unknown.elementType - May be null if the type is unknown.public void writeValue(Object value)
value - May be null.public void writeValue(Object value, Class knownType)
value - May be null.knownType - May be null if the type is unknown.public void writeValue(Object value, Class knownType, Class elementType)
value - May be null.knownType - May be null if the type is unknown.elementType - May be null if the type is unknown.public void writeObjectStart(String name)
public void writeObjectStart(String name, Class actualType, Class knownType)
knownType - May be null if the type is unknown.public void writeObjectStart()
public void writeObjectStart(Class actualType, Class knownType)
knownType - May be null if the type is unknown.public void writeObjectEnd()
public void writeArrayStart(String name)
public void writeArrayStart()
public void writeArrayEnd()
public void writeType(Class type)
public <T> T fromJson(Class<T> type, Reader reader)
type - May be null if the type is unknown.public <T> T fromJson(Class<T> type, Class elementType, Reader reader)
type - May be null if the type is unknown.elementType - May be null if the type is unknown.public <T> T fromJson(Class<T> type, InputStream input)
type - May be null if the type is unknown.public <T> T fromJson(Class<T> type, Class elementType, InputStream input)
type - May be null if the type is unknown.elementType - May be null if the type is unknown.public <T> T fromJson(Class<T> type, File file)
type - May be null if the type is unknown.public <T> T fromJson(Class<T> type, Class elementType, File file)
type - May be null if the type is unknown.elementType - May be null if the type is unknown.public <T> T fromJson(Class<T> type, char[] data, int offset, int length)
type - May be null if the type is unknown.public <T> T fromJson(Class<T> type, Class elementType, char[] data, int offset, int length)
type - May be null if the type is unknown.elementType - May be null if the type is unknown.public <T> T fromJson(Class<T> type, String json)
type - May be null if the type is unknown.public <T> T fromJson(Class<T> type, Class elementType, String json)
type - May be null if the type is unknown.public void readField(Object object, String fieldName, String jsonName, JsonValue jsonData)
public void readField(Object object, String fieldName, String jsonName, Class elementType, JsonValue jsonMap)
elementType - May be null if the type is unknown.public <T> T readValue(String name, Class<T> type, JsonValue jsonMap)
type - May be null if the type is unknown.public <T> T readValue(String name, Class<T> type, T defaultValue, JsonValue jsonMap)
type - May be null if the type is unknown.public <T> T readValue(String name, Class<T> type, Class elementType, JsonValue jsonMap)
type - May be null if the type is unknown.elementType - May be null if the type is unknown.public <T> T readValue(String name, Class<T> type, Class elementType, T defaultValue, JsonValue jsonMap)
type - May be null if the type is unknown.elementType - May be null if the type is unknown.public <T> T readValue(Class<T> type, Class elementType, T defaultValue, JsonValue jsonData)
type - May be null if the type is unknown.elementType - May be null if the type is unknown.public <T> T readValue(Class<T> type, JsonValue jsonData)
type - May be null if the type is unknown.public <T> T readValue(Class<T> type, Class elementType, JsonValue jsonData)
type - May be null if the type is unknown.elementType - May be null if the type is unknown.public String prettyPrint(Object object, JsonValue.PrettyPrintSettings settings)
public String prettyPrint(String json, JsonValue.PrettyPrintSettings settings)
Copyright © 2014. All Rights Reserved.