Class JsonUtils


  • public class JsonUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      JsonUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T deserialize​(java.lang.String json, java.lang.Class<T> type)  
      static java.lang.String getJSON​(java.nio.file.Path file)
      Given a Json file location, this method returns that JSON as a String
      static java.lang.String getJSONFromFile​(java.lang.String fileName)
      Given a Json file location, this method returns that JSON as a String
      static <T> T getJSONFromFileAsObject​(java.lang.String file, java.lang.Class<T> valueType)  
      static java.lang.String getJSONFromPath​(java.lang.String path)  
      static <T> java.util.List<T> getListJSONFromFileAsObject​(java.lang.String file, java.lang.Class<T> valueType)  
      static boolean isJSONValid​(java.lang.Object jsonObject)  
      static boolean isJSONValid​(java.lang.String json)  
      static java.lang.String prettyJsonToCompact​(java.lang.String prettyJson)  
      static java.lang.String replaceVarsFromPropertyManager​(java.lang.String jsonUnparsed)  
      static java.lang.String serialize​(java.lang.Object json)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JsonUtils

        public JsonUtils()
    • Method Detail

      • deserialize

        public static <T> T deserialize​(java.lang.String json,
                                        java.lang.Class<T> type)
      • serialize

        public static java.lang.String serialize​(java.lang.Object json)
      • isJSONValid

        public static boolean isJSONValid​(java.lang.Object jsonObject)
      • isJSONValid

        public static boolean isJSONValid​(java.lang.String json)
      • getJSONFromFile

        public static java.lang.String getJSONFromFile​(java.lang.String fileName)
                                                throws java.io.IOException
        Given a Json file location, this method returns that JSON as a String
        Parameters:
        fileName -
        Returns:
        String (json)
        Throws:
        java.io.IOException
      • getJSONFromPath

        public static java.lang.String getJSONFromPath​(java.lang.String path)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • getJSONFromFileAsObject

        public static <T> T getJSONFromFileAsObject​(java.lang.String file,
                                                    java.lang.Class<T> valueType)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getListJSONFromFileAsObject

        public static <T> java.util.List<T> getListJSONFromFileAsObject​(java.lang.String file,
                                                                        java.lang.Class<T> valueType)
                                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • getJSON

        public static java.lang.String getJSON​(java.nio.file.Path file)
                                        throws java.io.IOException
        Given a Json file location, this method returns that JSON as a String
        Parameters:
        file -
        Returns:
        String (json)
        Throws:
        java.io.IOException
      • prettyJsonToCompact

        public static java.lang.String prettyJsonToCompact​(java.lang.String prettyJson)
      • replaceVarsFromPropertyManager

        public static java.lang.String replaceVarsFromPropertyManager​(java.lang.String jsonUnparsed)
                                                               throws java.io.IOException
        Parameters:
        jsonUnparsed - json as String with Handlebars {{ }} to be replaced from propertyManager
        Returns:
        String with replaced handlebars vars
        Throws:
        java.io.IOException