Class JSONUtil


  • public class JSONUtil
    extends Object
    Deprecated.
    Use the JSON-P library instead, or the JsonUtil class in nucleus

    This class provides basic JSON encoding / decoding. It has 2 primary methods that are of interest. The first allows you to encode a Java Object into JSON. The other allows you to create a Java data structure from a JSON String. See:

    See Also:
    JsonUtil
    • Constructor Detail

      • JSONUtil

        public JSONUtil()
        Deprecated.
    • Method Detail

      • jsonToJava

        public static Object jsonToJava​(String json)
        Deprecated.

        This method returns a Java representation of the given JSON String. The Java data structure created will be created using Map's, String's, Long's, Float's, Boolean's, and List's as specified by the JSON String.

        Parameters:
        json -
        Returns:
      • javaToJSON

        public static String javaToJSON​(Object obj,
                                        int depth)
        Deprecated.

        This method attempts to convert the given Object into a JSON String to given depth. If -1 (or lower) is supplied for depth, it will walk upto a default depth of 10 levels of the given Object. If 0 is supplied, it will simply return "". 1 will encode the current Object, but no children. 2 will encode the given Object and its direct children (if any), and so on.

        Strings, Longs, Float, and primitives are considered to not have child Objects. Objects which have a public no-argument getXYZ() method are considered to be child Objects. Maps and Collections will be walked.

        Parameters:
        obj -
        depth -
        Returns:
      • appendUnicodeEscaped

        public static void appendUnicodeEscaped​(char ch,
                                                StringBuilder builder)
        Deprecated.