Class JsonTreeWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public final class JsonTreeWriter
    extends JsonWriter
    This writer creates a JsonElement.
    • Constructor Detail

      • JsonTreeWriter

        public JsonTreeWriter()
    • Method Detail

      • get

        public JsonElement get()
        Returns the top level object produced by this writer.
      • beginArray

        public JsonWriter beginArray()
                              throws java.io.IOException
        Description copied from class: JsonWriter
        Begins encoding a new array. Each call to this method must be paired with a call to JsonWriter.endArray().
        Overrides:
        beginArray in class JsonWriter
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • endArray

        public JsonWriter endArray()
                            throws java.io.IOException
        Description copied from class: JsonWriter
        Ends encoding the current array.
        Overrides:
        endArray in class JsonWriter
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • beginObject

        public JsonWriter beginObject()
                               throws java.io.IOException
        Description copied from class: JsonWriter
        Begins encoding a new object. Each call to this method must be paired with a call to JsonWriter.endObject().
        Overrides:
        beginObject in class JsonWriter
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • endObject

        public JsonWriter endObject()
                             throws java.io.IOException
        Description copied from class: JsonWriter
        Ends encoding the current object.
        Overrides:
        endObject in class JsonWriter
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • name

        public JsonWriter name​(java.lang.String name)
                        throws java.io.IOException
        Description copied from class: JsonWriter
        Encodes the property name.
        Overrides:
        name in class JsonWriter
        Parameters:
        name - the name of the forthcoming value. May not be null.
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • value

        public JsonWriter value​(java.lang.String value)
                         throws java.io.IOException
        Description copied from class: JsonWriter
        Encodes value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - the literal string value, or null to encode a null literal.
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • nullValue

        public JsonWriter nullValue()
                             throws java.io.IOException
        Description copied from class: JsonWriter
        Encodes null.
        Overrides:
        nullValue in class JsonWriter
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • value

        public JsonWriter value​(boolean value)
                         throws java.io.IOException
        Description copied from class: JsonWriter
        Encodes value.
        Overrides:
        value in class JsonWriter
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • value

        public JsonWriter value​(java.lang.Boolean value)
                         throws java.io.IOException
        Description copied from class: JsonWriter
        Encodes value.
        Overrides:
        value in class JsonWriter
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • value

        public JsonWriter value​(double value)
                         throws java.io.IOException
        Description copied from class: JsonWriter
        Encodes value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - a finite value. May not be NaNs or infinities.
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • value

        public JsonWriter value​(long value)
                         throws java.io.IOException
        Description copied from class: JsonWriter
        Encodes value.
        Overrides:
        value in class JsonWriter
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • value

        public JsonWriter value​(java.lang.Number value)
                         throws java.io.IOException
        Description copied from class: JsonWriter
        Encodes value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - a finite value. May not be NaNs or infinities.
        Returns:
        this writer.
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Description copied from class: JsonWriter
        Ensures all buffered data is written to the underlying Writer and flushes that writer.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class JsonWriter
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Description copied from class: JsonWriter
        Flushes and closes this writer and the underlying Writer.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class JsonWriter
        Throws:
        java.io.IOException - if the JSON document is incomplete.