public class JSONUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
JSONUtil.AsPropertyTypeSerializerEx
Required to suppress writing of type information except for top-level objects.
|
| Modifier and Type | Method and Description |
|---|---|
static Object |
deserialize(String data)
Deserializes an object from JSON format.
|
static Object |
deserialize(String typeProperty,
String data)
Deserializes an object from JSON format.
|
static <T> List<T> |
deserializeList(String data,
Class<T> clazz)
Deserializes a list of objects.
|
static <T> List<T> |
deserializeList(String typeProperty,
String data,
Class<T> clazz)
Deserializes a list of objects.
|
static String |
getAlias(Class<?> clazz)
Returns an alias given its associated class.
|
static com.fasterxml.jackson.databind.ObjectMapper |
getMapper()
Returns an instance of the mapper for the default type property.
|
static com.fasterxml.jackson.databind.ObjectMapper |
getMapper(String typeProperty)
Returns an instance of the mapper for the specified type property.
|
static com.fasterxml.jackson.databind.JsonNode |
merge(com.fasterxml.jackson.databind.JsonNode destNode,
com.fasterxml.jackson.databind.JsonNode srcNode)
Merges one JSON tree (srcNode) into another (destNode).
|
static com.fasterxml.jackson.databind.JsonNode |
merge(com.fasterxml.jackson.databind.JsonNode destNode,
com.fasterxml.jackson.databind.JsonNode srcNode,
boolean deleteOnNull)
Merges one JSON tree (srcNode) into another (destNode).
|
static void |
registerAlias(String alias,
Class<?> clazz)
Register an alias for the specified class.
|
static String |
serialize(Object object)
Serializes an object to JSON format.
|
static String |
serialize(Object object,
boolean prettyPrint)
Serializes an object to JSON format.
|
static String |
serialize(String typeProperty,
Object object)
Serializes an object to JSON format.
|
static String |
serialize(String typeProperty,
Object object,
boolean prettyPrint)
Serializes an object to JSON format.
|
static void |
setDateFormat(DateFormat dateFormat)
Sets the date format to be used when serializing dates.
|
static void |
setDateFormat(String typeProperty,
DateFormat dateFormat)
Sets the date format to be used when serializing dates.
|
static void |
unregisterAlias(String name)
Removes a registered alias.
|
public static com.fasterxml.jackson.databind.ObjectMapper getMapper()
public static com.fasterxml.jackson.databind.ObjectMapper getMapper(String typeProperty)
typeProperty - The name of the property signifying the data type.public static void registerAlias(String alias, Class<?> clazz)
alias - Alias to be used for serialization.clazz - Class to be associated with the alias.public static void unregisterAlias(String name)
name - Alias to be unregistered.public static final String getAlias(Class<?> clazz)
clazz - The class whose alias is sought.public static void setDateFormat(DateFormat dateFormat)
dateFormat - Date format to use.public static void setDateFormat(String typeProperty, DateFormat dateFormat)
typeProperty - The name of the property signifying the data type.dateFormat - Date format to use.public static String serialize(Object object)
object - Object to be serialized.public static String serialize(Object object, boolean prettyPrint)
object - Object to be serialized.prettyPrint - If true, format output for display.public static String serialize(String typeProperty, Object object)
typeProperty - The name of the property signifying the data type.object - Object to be serialized.public static String serialize(String typeProperty, Object object, boolean prettyPrint)
typeProperty - The name of the property signifying the data type.object - Object to be serialized.prettyPrint - If true, format output for display.public static Object deserialize(String data)
data - Serialized form of the object.public static Object deserialize(String typeProperty, String data)
typeProperty - The name of the property signifying the data type.data - Serialized form of the object.public static <T> List<T> deserializeList(String data, Class<T> clazz)
T - The list elements' class.data - Serialized form of the list in JSON format.clazz - The class of objects found in the list.public static <T> List<T> deserializeList(String typeProperty, String data, Class<T> clazz)
T - The list elements' class.typeProperty - The name of the property signifying the data type.data - Serialized form of the list in JSON format.clazz - The class of objects found in the list.public static com.fasterxml.jackson.databind.JsonNode merge(com.fasterxml.jackson.databind.JsonNode destNode,
com.fasterxml.jackson.databind.JsonNode srcNode)
destNode - The tree receiving the merged node.srcNode - The tree supplying the nodes to merge.public static com.fasterxml.jackson.databind.JsonNode merge(com.fasterxml.jackson.databind.JsonNode destNode,
com.fasterxml.jackson.databind.JsonNode srcNode,
boolean deleteOnNull)
destNode - The tree receiving the merged node.srcNode - The tree supplying the nodes to merge.deleteOnNull - If true and a null value is encountered in the source, delete the
corresponding node in the destination. If false, null values are treated like any
other value.Copyright © 2018 Regenstrief Center for Biomedical Informatics. All rights reserved.