Class Json
- java.lang.Object
-
- io.streamthoughts.azkarra.serialization.json.Json
-
public final class Json extends Object
Helper class for wrappingObjectMapper
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(Consumer<com.fasterxml.jackson.databind.ObjectMapper> configure)
com.fasterxml.jackson.databind.JsonNode
deserialize(byte[] data)
An helper method that can be used to deserialize a given bytes array.<T> T
deserialize(byte[] data, Class<T> type)
An helper method that can be used to deserialize a given bytes array.<T> T
deserialize(com.fasterxml.jackson.databind.JsonNode node, Class<T> type)
An helper method that can be used to deserialize a given bytes array.com.fasterxml.jackson.databind.JsonNode
deserialize(InputStream is)
An helper method that can be used to deserialize a givenInputStream
.<T> T
deserialize(InputStream is, Class<T> type)
An helper method that can be used to deserialize a givenInputStream
.<T> T
deserialize(String data, Class<T> type)
An helper method that can be used to deserialize a givenInputStream
.static Json
getDefault()
void
registerModule(com.fasterxml.jackson.databind.Module module)
void
registerModules(Iterable<? extends com.fasterxml.jackson.databind.Module> modules)
String
serialize(Object data)
An helper method that can be used to serialize a given object.com.fasterxml.jackson.databind.ObjectMapper
unwrap()
-
-
-
Constructor Detail
-
Json
public Json(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Creates a newJson
instance.- Parameters:
objectMapper
- theObjectMapper
.
-
-
Method Detail
-
getDefault
public static Json getDefault()
-
configure
public void configure(Consumer<com.fasterxml.jackson.databind.ObjectMapper> configure)
-
registerModules
public void registerModules(Iterable<? extends com.fasterxml.jackson.databind.Module> modules)
-
registerModule
public void registerModule(com.fasterxml.jackson.databind.Module module)
-
deserialize
public com.fasterxml.jackson.databind.JsonNode deserialize(InputStream is)
An helper method that can be used to deserialize a givenInputStream
.- Parameters:
is
- theInputStream
to read.- Returns:
- the
JsonNode
.
-
deserialize
public <T> T deserialize(InputStream is, Class<T> type)
An helper method that can be used to deserialize a givenInputStream
.- Parameters:
is
- theInputStream
to read.type
- the expected type.- Returns:
- the deserialized object.
-
deserialize
public <T> T deserialize(String data, Class<T> type)
An helper method that can be used to deserialize a givenInputStream
.- Parameters:
data
- the json string.type
- the expected type.- Returns:
- the deserialized object.
-
deserialize
public <T> T deserialize(byte[] data, Class<T> type)
An helper method that can be used to deserialize a given bytes array.- Parameters:
data
- the data to deserialize.type
- the expected type.- Returns:
- the deserialized object.
-
deserialize
public <T> T deserialize(com.fasterxml.jackson.databind.JsonNode node, Class<T> type)
An helper method that can be used to deserialize a given bytes array.- Parameters:
node
- the data to deserialize.type
- the expected type.- Returns:
- the deserialized object.
-
deserialize
public com.fasterxml.jackson.databind.JsonNode deserialize(byte[] data)
An helper method that can be used to deserialize a given bytes array.- Parameters:
data
- the data to deserialize.- Returns:
- the
JsonNode
.
-
serialize
public String serialize(Object data)
An helper method that can be used to serialize a given object.- Parameters:
data
- the object to serialize- Returns:
- the JSON string representation.
-
unwrap
public com.fasterxml.jackson.databind.ObjectMapper unwrap()
-
-