Class JsonUtils


  • public final class JsonUtils
    extends Object
    Author:
    svenkubiak
    • Method Detail

      • getObjectMapper

        public static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
        Returns:
        Default object mapper
      • toJson

        public static String toJson​(Object object)
        Converts a given object to a Json string
        Parameters:
        object - The object to convert
        Returns:
        json string or null if conversion fails
      • toPrettyJson

        public static String toPrettyJson​(Object object)
        Converts a given object to a Json string
        Parameters:
        object - The object to convert
        Returns:
        json string or null if conversion fails
      • fromJson

        public static com.jayway.jsonpath.ReadContext fromJson​(String json)
        Converts a given Json string to an JSONPath ReadContext
        Parameters:
        json - The json string to convert
        Returns:
        JSPNPath read context
      • fromJson

        public static <T> T fromJson​(String json,
                                     Class<T> clazz)
        Converts a given Json string to given Class
        Type Parameters:
        T - JavaDoc wants this, just ignore it
        Parameters:
        json - The json string to convert
        clazz - The Class to convert to
        Returns:
        The converted class or null if conversion fails