Package com.api.json

Class JSON

    • Field Detail

      • BLANKS

        public static String BLANKS
      • BLANKSTR

        public static String BLANKSTR
      • ESCAPE_SOLIDUS

        protected static boolean ESCAPE_SOLIDUS
      • INCR

        public static int INCR
      • LN_CNTR

        public static int LN_CNTR
      • LN_OFFSET

        public static int LN_OFFSET
    • Constructor Detail

      • JSON

        public JSON()
    • Method Detail

      • cleanUpString

        protected static String cleanUpString​(Object obj)
        Provides special formatting of embedded characters to enable valid JSON serialization
        Parameters:
        obj - Object to be formatted
        Returns:
        Formatted String representation of the supplied object with appropriate expanded character sequences.
      • escapeSolidus

        public static void escapeSolidus​(boolean set)
        Use to set or unset escaping solidus characters in the output. By default, this is set to true for compatibility.
        Parameters:
        set - If true, solidus is printed as \/ rather than /
      • expandUnicode

        protected static String expandUnicode​(String input)
        Expands the input String content to unicode sequences for non ASCII characters
        Parameters:
        input - String to be formatted
        Returns:
        Formatted output String
      • getNumber

        protected static Object getNumber​(Double dNum,
                                          String value)
        Parses the number corresponding with the supplied values. Used to ensure either a Long or a Double will be used to represent numeric values in JSON.
        Parameters:
        dNum - Double containing the numeric value of the String value
        value - String representation of the value.
        Returns:
        A Long or a Double parsed from the supplied values.
      • isValidObject

        public static boolean isValidObject​(Object object)
        Used to determine if the supplied Object can be a valid JSON object.
        Parameters:
        object - Object to be tested.
        Returns:
        True if the supplied Object is a valid JSON object.
      • isValidType

        public static boolean isValidType​(Class<?> clazz)
        Used to determine in the supplied Class is a valid type for JSON objects. Valid types are: String, Boolean, Integer, Double, Long, Byte, Short, Float, JSONObject, or JSONArray
        Parameters:
        clazz - The Class to be tested.
        Returns:
        True if the supplied class is a valid type for JSON objects.
      • setSpacing

        public static void setSpacing​(int size)
        Provides a String of blanks for indentation (up to 60 spaces) corresponding to the supplied indentation size.
        Parameters:
        size - the desired indentation size.