Package edu.byu.hbll.box.internal.util
Class JsonUtils
- java.lang.Object
-
- edu.byu.hbll.box.internal.util.JsonUtils
-
public class JsonUtils extends Object
Json utilities.
-
-
Constructor Summary
Constructors Constructor Description JsonUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
bind(com.fasterxml.jackson.databind.JsonNode node, Object object)
Binds the givenJsonNode
to the provided object.static void
bind(com.fasterxml.jackson.databind.JsonNode node, Map<String,com.fasterxml.jackson.databind.JsonNode> values)
Binds values in the map to the givenJsonNode
.static com.fasterxml.jackson.databind.JsonNode
deserialize(String value)
Deserializes the string to aJsonNode
.static com.fasterxml.jackson.databind.JsonNode
dotPath(com.fasterxml.jackson.databind.JsonNode node, String dotPath)
Return the foundJsonNode
after following the dot notation path.static String
serialize(Object document)
Serializes the document to a string.static com.fasterxml.jackson.databind.JsonNode
toJsonNode(Object value)
Converts an object to aJsonNode
.
-
-
-
Method Detail
-
bind
public static void bind(com.fasterxml.jackson.databind.JsonNode node, Map<String,com.fasterxml.jackson.databind.JsonNode> values)
Binds values in the map to the givenJsonNode
. The key in the map is the name of the variable in the node. The value in the map replaces the ${VARIABLE_NAME} in the node.- Parameters:
node
- the node to modifyvalues
- the values to bind to the node
-
bind
public static void bind(com.fasterxml.jackson.databind.JsonNode node, Object object)
Binds the givenJsonNode
to the provided object.- Parameters:
node
- the values to bindobject
- values are bound to this object
-
deserialize
public static com.fasterxml.jackson.databind.JsonNode deserialize(String value)
Deserializes the string to aJsonNode
.- Parameters:
value
- the string to deserialize- Returns:
- the deserialized node
-
dotPath
public static com.fasterxml.jackson.databind.JsonNode dotPath(com.fasterxml.jackson.databind.JsonNode node, String dotPath)
Return the foundJsonNode
after following the dot notation path.- Parameters:
node
- the subectdotPath
- the path- Returns:
- the found node or missing node if none found
-
serialize
public static String serialize(Object document)
Serializes the document to a string.- Parameters:
document
- the document to serialize.- Returns:
- the serialized string
-
toJsonNode
public static com.fasterxml.jackson.databind.JsonNode toJsonNode(Object value)
Converts an object to aJsonNode
.- Parameters:
value
- the object to convert- Returns:
- the resulting
JsonNode
-
-