public class SerializationUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
fromJsonString(java.lang.String str,
java.lang.Class<T> clazz)
Returns the object represented by the provided JSON string created via
toJsonString(Object) . |
static <T> T |
fromString(java.lang.String str,
java.lang.Class<T> clazz,
ObjectMapper mapper)
Returns a representation of the provided value using the provided custom object mapper.
|
static <T> T |
fromYamlString(java.lang.String str,
java.lang.Class<T> clazz)
Returns the object represented by the provided YAML string created via
toYamlString(Object) . |
static ObjectMapper |
registerDefaultModules(ObjectMapper mapper)
Returns a new
ObjectMapper with default modules against the provided factory. |
static <T> java.lang.String |
toJsonString(T value)
Returns a JSON representation of the provided value.
|
static <T> java.lang.String |
toJsonStringOrEmpty(T value)
Returns a JSON representation of the provided value, or an empty string if conversion fails.
|
static <T> java.lang.String |
toString(T value,
ObjectMapper mapper)
Returns a representation of the provided value using the provided custom object mapper.
|
static <T> java.lang.String |
toYamlString(T value)
Returns a YAML representation of the provided value.
|
static <T> java.lang.String |
toYamlStringOrEmpty(T value)
Returns a JSON representation of the provided value, or an empty string if conversion fails.
|
public static ObjectMapper registerDefaultModules(ObjectMapper mapper)
ObjectMapper
with default modules against the provided factory.mapper
- the instance to register default modules withpublic static <T> java.lang.String toYamlString(T value) throws java.io.IOException
T
- The type of the value
value
- The value that will be converted to YAMLvalue
java.io.IOException
- if conversion failspublic static <T> java.lang.String toYamlStringOrEmpty(T value)
Object.toString()
.T
- The type of the value
value
- The value that will be converted to JSONvalue
, or an empty string if conversion failspublic static <T> T fromYamlString(java.lang.String str, java.lang.Class<T> clazz) throws java.io.IOException
toYamlString(Object)
.java.io.IOException
public static <T> java.lang.String toJsonString(T value) throws java.io.IOException
T
- The type of the value
value
- The value that will be converted to JSONvalue
java.io.IOException
- if conversion failspublic static <T> java.lang.String toJsonStringOrEmpty(T value)
Object.toString()
.T
- The type of the value
value
- The value that will be converted to JSONvalue
, or an empty string if conversion failspublic static <T> T fromJsonString(java.lang.String str, java.lang.Class<T> clazz) throws java.io.IOException
toJsonString(Object)
.java.io.IOException
public static <T> java.lang.String toString(T value, ObjectMapper mapper) throws java.io.IOException
java.io.IOException
public static <T> T fromString(java.lang.String str, java.lang.Class<T> clazz, ObjectMapper mapper) throws java.io.IOException
java.io.IOException