Package com.api.json

Class JSONArray

    • Constructor Detail

      • JSONArray

        public JSONArray()
        Constructor
      • JSONArray

        public JSONArray​(int intialCapacity)
        Constructor with initial capacity allocated
        Parameters:
        intialCapacity - initial size for the array
    • Method Detail

      • serialize

        public String serialize()
                         throws IOException
        Description copied from interface: JSONArtifact
        Convert this object into a String of JSON text.
        Specified by:
        serialize in interface JSONArtifact
        Returns:
        String containing the JSON formatted according to the verbose flag.
        Throws:
        IOException - Thrown on IO errors during serialization.
      • serialize

        public String serialize​(boolean verbose)
                         throws IOException
        Specified by:
        serialize in interface JSONArtifact
        Parameters:
        verbose - Whether or not to write the JSON text in a verbose format.
        Returns:
        String containing the JSON formatted according to the verbose flag.
        Throws:
        IOException - Thrown on IO errors during serialization.
      • serialize

        public void serialize​(OutputStream os)
                       throws IOException
        Description copied from interface: JSONArtifact
        Convert this object into a stream of JSON text. Same as calling serialize(os,false); Note that encoding is always written as UTF-8, as per JSON spec.
        Specified by:
        serialize in interface JSONArtifact
        Parameters:
        os - The output stream to serialize data to.
        Throws:
        IOException - Thrown on IO errors during serialization.
      • serialize

        public void serialize​(OutputStream os,
                              boolean verbose)
                       throws IOException
        Description copied from interface: JSONArtifact
        Convert this object into a stream of JSON text. Same as calling serialize(writer,false); Note that encoding is always written as UTF-8, as per JSON spec.
        Specified by:
        serialize in interface JSONArtifact
        Parameters:
        os - The output stream to serialize data to.
        verbose - Whether or not to write the JSON text in a verbose format.
        Throws:
        IOException - Thrown on IO errors during serialization.
      • serialize

        public void serialize​(Writer writer)
                       throws IOException
        Description copied from interface: JSONArtifact
        Convert this object into a stream of JSON text. Same as calling serialize(writer,false);
        Specified by:
        serialize in interface JSONArtifact
        Parameters:
        writer - The writer which to serialize the JSON text to.
        Throws:
        IOException - Thrown on IO errors during serialization.
      • serialize

        public void serialize​(Writer writer,
                              boolean verbose)
                       throws IOException
        Description copied from interface: JSONArtifact
        Convert this object into a stream of JSON text, specifying verbosity.
        Specified by:
        serialize in interface JSONArtifact
        Parameters:
        writer - The writer which to serialize the JSON text to.
        verbose - Whether or not to write the JSON text in a verbose format.
        Throws:
        IOException - Thrown on IO errors during serialization.
      • toString

        public String toString​(StringBuilder sb,
                               int indent,
                               int incr)
        Description copied from interface: JSONArtifact
        Abstract method to help with recursive formatting of JSON into a String
        Specified by:
        toString in interface JSONArtifact
        Parameters:
        sb - Buffer to receive formatted JSON content
        indent - The amount of indentation expected in the formatted output.
        incr - the amount of incremental spacing used for formatted output.
        Returns:
        Formatted JSON output.