public class JsonUtils extends Object
| Constructor and Description |
|---|
JsonUtils() |
| Modifier and Type | Method and Description |
|---|---|
static com.fasterxml.jackson.databind.ObjectMapper |
createObjectMapper()
creates a new
ObjectMapper instance |
static com.fasterxml.jackson.databind.ObjectMapper |
createObjectMapper(ModuleOptions options) |
static <T> T |
fromInputStream(InputStream content,
Class<T> clazz)
deserializes the given json string to the given class
|
static <T> T |
fromJsonByteArray(byte[] content,
Class<T> clazz)
deserializes the given json string to the given class
|
static <T> T |
fromJsonString(String content,
Class<T> clazz)
deserializes the given json string to the given class
|
static com.fasterxml.jackson.databind.ObjectMapper |
getConfiguredObjectMapper()
default
ObjectMapper |
static String |
prettyPrint(String json)
Pretty prints a given JSON string.
|
static byte[] |
toJsonByteArray(Object value)
serializes the given object to JSON as a byte array
|
static String |
toJsonString(Object value)
serializes the given object to JSON as a byte array
|
public static com.fasterxml.jackson.databind.ObjectMapper createObjectMapper()
ObjectMapper instancepublic static com.fasterxml.jackson.databind.ObjectMapper createObjectMapper(ModuleOptions options)
options - configuration for jackson modules supplied by a ModuleSupplierpublic static byte[] toJsonByteArray(Object value) throws com.fasterxml.jackson.core.JsonProcessingException
value - object to be serializedcom.fasterxml.jackson.core.JsonProcessingException - serialization errorspublic static String toJsonString(Object value) throws com.fasterxml.jackson.core.JsonProcessingException
value - object to be serializedcom.fasterxml.jackson.core.JsonProcessingException - serialization errorspublic static <T> T fromJsonString(String content, Class<T> clazz) throws IOException
clazz - class to serialize tocontent - json as stringIOException - deserialization errorspublic static <T> T fromJsonByteArray(byte[] content,
Class<T> clazz)
throws IOException
clazz - class to serialize tocontent - json as byte arrayIOException - deserialization errorspublic static <T> T fromInputStream(InputStream content, Class<T> clazz) throws IOException
clazz - class to serialize tocontent - json as inputstreamIOException - deserialization errorspublic static com.fasterxml.jackson.databind.ObjectMapper getConfiguredObjectMapper()
ObjectMapper