Class JSONArray

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static long serialVersionUID  
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      JSONArray()  
      JSONArray​(int initialCapacity)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      JSONArray appendElement​(java.lang.Object element)
      Appends the specified element and returns this.
      void merge​(java.lang.Object o2)
      Merges the specified object into this array.
      java.lang.String toJSONString()
      Explicitly Serialize Object as JSon String
      static java.lang.String toJSONString​(java.util.List<? extends java.lang.Object> list)  
      static java.lang.String toJSONString​(java.util.List<? extends java.lang.Object> list, JSONStyle compression)
      Convert a list to JSON text.
      java.lang.String toJSONString​(JSONStyle compression)
      Converts this object to JSON string representation with specified compression style.
      java.lang.String toString()
      Override native toString()
      java.lang.String toString​(JSONStyle compression)
      JSONAwareEx interface
      void writeJSONString​(java.lang.Appendable out)
      JSONStreamAwareEx interface
      void writeJSONString​(java.lang.Appendable out, JSONStyle compression)
      JSONStreamAwareEx interface
      static void writeJSONString​(java.lang.Iterable<? extends java.lang.Object> list, java.lang.Appendable out, JSONStyle compression)
      Encode a list into JSON text and write it to out.
      static void writeJSONString​(java.util.List<? extends java.lang.Object> list, java.lang.Appendable out)
      Encode a list into JSON text and write it to out.
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractCollection

        containsAll
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.util.List

        containsAll
    • Constructor Detail

      • JSONArray

        public JSONArray()
      • JSONArray

        public JSONArray​(int initialCapacity)
    • Method Detail

      • toJSONString

        public static java.lang.String toJSONString​(java.util.List<? extends java.lang.Object> list)
      • toJSONString

        public static java.lang.String toJSONString​(java.util.List<? extends java.lang.Object> list,
                                                    JSONStyle compression)
        Convert a list to JSON text. The result is a JSON array. If this list is also a JSONAware, JSONAware specific behaviours will be omitted at this top level.
        Parameters:
        list -
        compression - Indicate compression level
        Returns:
        JSON text, or "null" if list is null.
        See Also:
        JSONValue.toJSONString(Object)
      • writeJSONString

        public static void writeJSONString​(java.lang.Iterable<? extends java.lang.Object> list,
                                           java.lang.Appendable out,
                                           JSONStyle compression)
                                    throws java.io.IOException
        Encode a list into JSON text and write it to out. If this list is also a JSONStreamAware or a JSONAware, JSONStreamAware and JSONAware specific behaviours will be ignored at this top level.
        Parameters:
        list -
        out -
        Throws:
        java.io.IOException
        See Also:
        JSONValue.writeJSONString(Object, Appendable)
      • writeJSONString

        public static void writeJSONString​(java.util.List<? extends java.lang.Object> list,
                                           java.lang.Appendable out)
                                    throws java.io.IOException
        Encode a list into JSON text and write it to out. If this list is also a JSONStreamAware or a JSONAware, JSONStreamAware and JSONAware specific behaviours will be ignored at this top level.
        Parameters:
        list -
        out -
        Throws:
        java.io.IOException
      • appendElement

        public JSONArray appendElement​(java.lang.Object element)
        Appends the specified element and returns this. same effect that add(E e) method.
        Parameters:
        element - element to be appended to this array.
        Returns:
        this
      • merge

        public void merge​(java.lang.Object o2)
        Merges the specified object into this array. can trigger an add(E e) or addAll(E e) method.
        Parameters:
        o2 -
      • toJSONString

        public java.lang.String toJSONString()
        Explicitly Serialize Object as JSon String
        Specified by:
        toJSONString in interface JSONAware
        Returns:
        JSON text
      • toJSONString

        public java.lang.String toJSONString​(JSONStyle compression)
        Description copied from interface: JSONAwareEx
        Converts this object to JSON string representation with specified compression style.
        Specified by:
        toJSONString in interface JSONAwareEx
        Parameters:
        compression - the JSON style for formatting
        Returns:
        JSON text
      • toString

        public java.lang.String toString()
        Override native toString()
        Overrides:
        toString in class java.util.AbstractCollection<java.lang.Object>
      • toString

        public java.lang.String toString​(JSONStyle compression)
        JSONAwareEx interface
        Parameters:
        compression - compression param
      • writeJSONString

        public void writeJSONString​(java.lang.Appendable out)
                             throws java.io.IOException
        JSONStreamAwareEx interface
        Specified by:
        writeJSONString in interface JSONStreamAware
        Parameters:
        out - output stream
        Throws:
        java.io.IOException - if I/O error occurs
      • writeJSONString

        public void writeJSONString​(java.lang.Appendable out,
                                    JSONStyle compression)
                             throws java.io.IOException
        JSONStreamAwareEx interface
        Specified by:
        writeJSONString in interface JSONStreamAwareEx
        Parameters:
        out - output stream
        compression - compression param
        Throws:
        java.io.IOException - if I/O error occurs