|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.restfb.DefaultJsonMapper
public class DefaultJsonMapper
Default implementation of a JSON-to-Java mapper.
| Nested Class Summary | |
|---|---|
static interface |
DefaultJsonMapper.JsonMappingErrorHandler
Callback interface which allows client code to specify how JSON mapping errors should be handled. |
| Constructor Summary | |
|---|---|
DefaultJsonMapper()
Creates a JSON mapper which will throw FacebookJsonMappingException whenever an error
occurs when mapping JSON data to Java objects. |
|
DefaultJsonMapper(DefaultJsonMapper.JsonMappingErrorHandler jsonMappingErrorHandler)
Creates a JSON mapper which delegates to the provided jsonMappingErrorHandler for handling mapping errors. |
|
| Method Summary | ||
|---|---|---|
|
toJavaList(String json,
Class<T> type)
Given a JSON string, create and return a new instance of a corresponding Java List which contains elements of type type. |
|
|
toJavaObject(String json,
Class<T> type)
Given a JSON string, create and return a new instance of a corresponding Java object of type type. |
|
String |
toJson(Object object)
Given a Java object, create and return a JSON string that
represents it. |
|
String |
toJson(Object object,
boolean ignoreNullValuedProperties)
Given a Java object, create and return a JSON string that
represents it. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultJsonMapper()
FacebookJsonMappingException whenever an error
occurs when mapping JSON data to Java objects.
public DefaultJsonMapper(DefaultJsonMapper.JsonMappingErrorHandler jsonMappingErrorHandler)
jsonMappingErrorHandler for handling mapping errors.
jsonMappingErrorHandler - The JSON mapping error handler to use.
IllegalArgumentException - If jsonMappingErrorHandler is null.| Method Detail |
|---|
public <T> List<T> toJavaList(String json,
Class<T> type)
JsonMapperList which contains elements of type type.
The Java type must have a no-argument constructor.
toJavaList in interface JsonMapperT - Java type to map to for each element of the list.json - The JSON to be mapped to a Java type.type - Java type token.
List which contains elements of type
type) representation of the JSON input.JsonMapper.toJavaList(java.lang.String, java.lang.Class)
public <T> T toJavaObject(String json,
Class<T> type)
JsonMappertype.
The Java type must have a no-argument constructor.
toJavaObject in interface JsonMapperT - Java type to map to.json - The JSON to be mapped to a Java type.type - Java type token.
type) representation of the JSON
input.JsonMapper.toJavaObject(java.lang.String, java.lang.Class)public String toJson(Object object)
JsonMapperobject, create and return a JSON string that
represents it.
The object's properties will be traversed recursively, allowing for
arbitrarily complex JSON generation.
toJson in interface JsonMapperobject - The Java object to map to JSON. Can be a Javabean,
List, or Map.
JsonMapper.toJson(java.lang.Object)
public String toJson(Object object,
boolean ignoreNullValuedProperties)
JsonMapperobject, create and return a JSON string that
represents it.
The object's properties will be traversed recursively, allowing for
arbitrarily complex JSON generation.
toJson in interface JsonMapperobject - The Java object to map to JSON. Can be a Javabean,
List, or Map.ignoreNullValuedProperties - If true, no Javabean properties with null values
will be included in the generated JSON.
JsonMapper.toJson(java.lang.Object, boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||