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.
|
<T> T |
convertValue(Object object,
com.fasterxml.jackson.databind.JavaType toValueTypeRef)
Converts one object into another.
|
com.fasterxml.jackson.databind.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,
com.fasterxml.jackson.core.type.TypeReference<T> typeReference)
Converts a JSON string into an object.
|
void |
setMapper(com.fasterxml.jackson.databind.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(com.fasterxml.jackson.databind.ObjectMapper mapper)
ObjectMapper.mapper - a new object mapper. must not be nullpublic com.fasterxml.jackson.databind.ObjectMapper getMapper()
ObjectMapperpublic String writeValueAsString(Object obj)
obj - the source objectnull if an exception occurredpublic 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 occurredpublic <T> T readValue(String json, com.fasterxml.jackson.core.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 createpublic <T> T convertValue(Object object, Class<T> clazz)
object - the sourceclazz - the type of the targetpublic <T> T convertValue(Object object, com.fasterxml.jackson.databind.JavaType toValueTypeRef)
object - the sourcetoValueTypeRef - the type of the targetCopyright © 2010-2014. All Rights Reserved.