Class 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 given JsonNode 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 given JsonNode.
      static com.fasterxml.jackson.databind.JsonNode deserialize​(String value)
      Deserializes the string to a JsonNode.
      static com.fasterxml.jackson.databind.JsonNode dotPath​(com.fasterxml.jackson.databind.JsonNode node, String dotPath)
      Return the found JsonNode 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 a JsonNode.
    • Constructor Detail

      • JsonUtils

        public JsonUtils()
    • 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 given JsonNode. 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 modify
        values - the values to bind to the node
      • bind

        public static void bind​(com.fasterxml.jackson.databind.JsonNode node,
                                Object object)
        Binds the given JsonNode to the provided object.
        Parameters:
        node - the values to bind
        object - values are bound to this object
      • deserialize

        public static com.fasterxml.jackson.databind.JsonNode deserialize​(String value)
        Deserializes the string to a JsonNode.
        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 found JsonNode after following the dot notation path.
        Parameters:
        node - the subect
        dotPath - 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 a JsonNode.
        Parameters:
        value - the object to convert
        Returns:
        the resulting JsonNode