Class Json


  • public final class Json
    extends Object
    Helper class for wrapping ObjectMapper.
    • Constructor Detail

      • Json

        public Json​(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
        Creates a new Json instance.
        Parameters:
        objectMapper - the ObjectMapper.
    • Method Detail

      • getDefault

        public static Json getDefault()
      • configure

        public void configure​(Consumer<com.fasterxml.jackson.databind.ObjectMapper> configure)
      • registerModules

        public void registerModules​(Iterable<? extends com.fasterxml.jackson.databind.Module> modules)
      • registerModule

        public void registerModule​(com.fasterxml.jackson.databind.Module module)
      • deserialize

        public com.fasterxml.jackson.databind.JsonNode deserialize​(InputStream is)
        An helper method that can be used to deserialize a given InputStream.
        Parameters:
        is - the InputStream to read.
        Returns:
        the JsonNode.
      • deserialize

        public <T> T deserialize​(InputStream is,
                                 Class<T> type)
        An helper method that can be used to deserialize a given InputStream.
        Parameters:
        is - the InputStream to read.
        type - the expected type.
        Returns:
        the deserialized object.
      • deserialize

        public <T> T deserialize​(String data,
                                 Class<T> type)
        An helper method that can be used to deserialize a given InputStream.
        Parameters:
        data - the json string.
        type - the expected type.
        Returns:
        the deserialized object.
      • deserialize

        public <T> T deserialize​(byte[] data,
                                 Class<T> type)
        An helper method that can be used to deserialize a given bytes array.
        Parameters:
        data - the data to deserialize.
        type - the expected type.
        Returns:
        the deserialized object.
      • deserialize

        public <T> T deserialize​(com.fasterxml.jackson.databind.JsonNode node,
                                 Class<T> type)
        An helper method that can be used to deserialize a given bytes array.
        Parameters:
        node - the data to deserialize.
        type - the expected type.
        Returns:
        the deserialized object.
      • deserialize

        public com.fasterxml.jackson.databind.JsonNode deserialize​(byte[] data)
        An helper method that can be used to deserialize a given bytes array.
        Parameters:
        data - the data to deserialize.
        Returns:
        the JsonNode.
      • serialize

        public String serialize​(Object data)
        An helper method that can be used to serialize a given object.
        Parameters:
        data - the object to serialize
        Returns:
        the JSON string representation.
      • unwrap

        public com.fasterxml.jackson.databind.ObjectMapper unwrap()