Class JsonWriter

  • Direct Known Subclasses:
    PrettyJsonWriter

    public class JsonWriter
    extends java.lang.Object
    IO-optimized JSON writer.
    • Constructor Detail

      • JsonWriter

        public JsonWriter​(java.io.OutputStream out)
      • JsonWriter

        public JsonWriter​(java.io.PrintWriter writer)
    • Method Detail

      • reset

        protected void reset()
        Reset the state of the writer and flush already written content.
      • flush

        public void flush()
        Flush the internal writer.
      • object

        public JsonWriter object()
        Start an object value.
        Returns:
        The JSON Writer.
      • array

        public JsonWriter array()
        Start an array value.
        Returns:
        The JSON Writer.
      • endObject

        public JsonWriter endObject()
        The the ongoing object.
        Returns:
        The JSON Writer.
      • endArray

        public JsonWriter endArray()
        End the ongoing array.
        Returns:
        The JSON Writer.
      • key

        public JsonWriter key​(boolean key)
        Write the boolean as object key.
        Parameters:
        key - The boolean key.
        Returns:
        The JSON Writer.
      • key

        public JsonWriter key​(byte key)
        Write the byte as object key.
        Parameters:
        key - The byte key.
        Returns:
        The JSON Writer.
      • key

        public JsonWriter key​(short key)
        Write the short as object key.
        Parameters:
        key - The short key.
        Returns:
        The JSON Writer.
      • key

        public JsonWriter key​(int key)
        Write the int as object key.
        Parameters:
        key - The int key.
        Returns:
        The JSON Writer.
      • key

        public JsonWriter key​(long key)
        Write the long as object key.
        Parameters:
        key - The long key.
        Returns:
        The JSON Writer.
      • key

        public JsonWriter key​(double key)
        Write the double as object key.
        Parameters:
        key - The double key.
        Returns:
        The JSON Writer.
      • key

        public JsonWriter key​(java.lang.CharSequence key)
        Write the string as object key.
        Parameters:
        key - The string key.
        Returns:
        The JSON Writer.
      • keyUnescaped

        public JsonWriter keyUnescaped​(java.lang.CharSequence key)
        Write the string as object key without escaping.
        Parameters:
        key - The string key.
        Returns:
        The JSON Writer.
      • key

        public JsonWriter key​(Binary key)
        Write the binary as object key.
        Parameters:
        key - The binary key.
        Returns:
        The JSON Writer.
      • keyLiteral

        public JsonWriter keyLiteral​(java.lang.CharSequence key)
        Write the string key without quoting or escaping.
        Parameters:
        key - The raw string key.
        Returns:
        The JSON Writer.
      • value

        public JsonWriter value​(boolean value)
        Write boolean value.
        Parameters:
        value - The boolean value.
        Returns:
        The JSON Writer.
      • value

        public JsonWriter value​(byte value)
        Write byte value.
        Parameters:
        value - The byte value.
        Returns:
        The JSON Writer.
      • value

        public JsonWriter value​(short value)
        Write short value.
        Parameters:
        value - The short value.
        Returns:
        The JSON Writer.
      • value

        public JsonWriter value​(int value)
        Write int value.
        Parameters:
        value - The int value.
        Returns:
        The JSON Writer.
      • value

        public JsonWriter value​(long value)
        Write long value.
        Parameters:
        value - The long value.
        Returns:
        The JSON Writer.
      • value

        public JsonWriter value​(double value)
        Write double value.
        Parameters:
        value - The double value.
        Returns:
        The JSON Writer.
      • value

        public JsonWriter value​(java.lang.CharSequence value)
        Write unicode string value.
        Parameters:
        value - The string value.
        Returns:
        The JSON Writer.
      • valueUnescaped

        public JsonWriter valueUnescaped​(java.lang.CharSequence value)
        Write a string unescaped value.
        Parameters:
        value - The string value.
        Returns:
        The JSON Writer.
      • value

        public JsonWriter value​(Binary value)
        Write binary value.
        Parameters:
        value - The binary value.
        Returns:
        The JSON Writer.
      • valueLiteral

        public JsonWriter valueLiteral​(java.lang.CharSequence value)
        Write a literal string as value. Not quoted and not escaped.
        Parameters:
        value - The raw string value.
        Returns:
        The JSON Writer.
      • startKey

        protected void startKey()
      • startValue

        protected boolean startValue()