public class JsonHandler extends Object
ObjectMapper and provides convenient methods.| Constructor and Description |
|---|
JsonHandler() |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
convertValue(Object object,
Class<T> clazz)
Converts one object into another.
|
org.codehaus.jackson.map.ObjectMapper |
getMapper() |
Object |
readValue(InputStream is,
Class<Object> clazz)
Converts a JSON string into an object.
|
<T> T |
readValue(String json,
Class<T> clazz)
Converts a JSON string into an object.
|
<T> T |
readValue(String json,
org.codehaus.jackson.type.TypeReference<T> typeReference)
Converts a JSON string into an object.
|
void |
setMapper(org.codehaus.jackson.map.ObjectMapper mapper)
Sets a new instance of
ObjectMapper. |
String |
writeValueAsString(Object obj)
Converts an object into a JSON string.
|
String |
writeValueAsString(Object obj,
boolean indent)
Converts an object into a JSON string.
|
public void setMapper(org.codehaus.jackson.map.ObjectMapper mapper)
ObjectMapper.mapper - a new object mapper. must not be nullpublic org.codehaus.jackson.map.ObjectMapper getMapper()
ObjectMapperpublic String writeValueAsString(Object obj)
obj - the source objectnull if an exception occuredpublic String writeValueAsString(Object obj, boolean indent)
obj - the source objectindent - if true JSON is written in a human readable format, if
false JSON is written on one linenull if an exception occuredpublic <T> T readValue(String json, org.codehaus.jackson.type.TypeReference<T> typeReference)
T - type of the object to createjson - string with the JSONtypeReference - TypeReference instance of the desired result
type TypeReferencepublic <T> T readValue(String json, Class<T> clazz)
T - type of the object to createjson - string with the JSONclazz - class of object to createpublic Object readValue(InputStream is, Class<Object> clazz)
is - a InputStreamclazz - class of object to createCopyright © 2010-2012. All Rights Reserved.