Module json5

Class JSONStringify


  • public class JSONStringify
    extends java.lang.Object
    A utility class for serializing JSONObjects and JSONArrays into their string representations
    Author:
    SyntaxError404
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String toString​(JSONArray array, int indentFactor)
      Converts a JSONArray into its string representation.
      static java.lang.String toString​(JSONArray array, int indentFactor, JSONOptions options)
      Converts a JSONArray into its string representation.
      static java.lang.String toString​(JSONObject object, int indentFactor)
      Converts a JSONObject into its string representation.
      static java.lang.String toString​(JSONObject object, int indentFactor, JSONOptions options)
      Converts a JSONObject into its string representation.
      • Methods inherited from class java.lang.Object

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

      • toString

        public static java.lang.String toString​(JSONObject object,
                                                int indentFactor,
                                                JSONOptions options)
        Converts a JSONObject into its string representation. The indentation factor enables pretty-printing and defines how many spaces (' ') should be placed before each key/value pair. A factor of < 1 disables pretty-printing and discards any optional whitespace characters.

        indentFactor = 2:

         {
           "key0": "value0",
           "key1": {
             "nested": 123
           },
           "key2": false
         }
         

        indentFactor = 0:

         {"key0":"value0","key1":{"nested":123},"key2":false}
         
        Parameters:
        object - the JSONObject
        indentFactor - the indentation factor
        options - the options for stringifying
        Returns:
        the string representation
        Since:
        1.1.0
      • toString

        public static java.lang.String toString​(JSONArray array,
                                                int indentFactor,
                                                JSONOptions options)
        Converts a JSONArray into its string representation. The indentation factor enables pretty-printing and defines how many spaces (' ') should be placed before each value. A factor of < 1 disables pretty-printing and discards any optional whitespace characters.

        indentFactor = 2:

         [
           "value",
           {
             "nested": 123
           },
           false
         ]
         

        indentFactor = 0:

         ["value",{"nested":123},false]
         
        Parameters:
        array - the JSONArray
        indentFactor - the indentation factor
        options - the options for stringifying
        Returns:
        the string representation
        Since:
        1.1.0
      • toString

        public static java.lang.String toString​(JSONObject object,
                                                int indentFactor)
        Converts a JSONObject into its string representation. The indentation factor enables pretty-printing and defines how many spaces (' ') should be placed before each key/value pair. A factor of < 1 disables pretty-printing and discards any optional whitespace characters.

        indentFactor = 2:

         {
           "key0": "value0",
           "key1": {
             "nested": 123
           },
           "key2": false
         }
         

        indentFactor = 0:

         {"key0":"value0","key1":{"nested":123},"key2":false}
         
        This uses the default options
        Parameters:
        object - the JSONObject
        indentFactor - the indentation factor
        Returns:
        the string representation
      • toString

        public static java.lang.String toString​(JSONArray array,
                                                int indentFactor)
        Converts a JSONArray into its string representation. The indentation factor enables pretty-printing and defines how many spaces (' ') should be placed before each value. A factor of < 1 disables pretty-printing and discards any optional whitespace characters.

        indentFactor = 2:

         [
           "value",
           {
             "nested": 123
           },
           false
         ]
         

        indentFactor = 0:

         ["value",{"nested":123},false]
         
        This uses the default options
        Parameters:
        array - the JSONArray
        indentFactor - the indentation factor
        Returns:
        the string representation