Class PrettyJsonWriter


  • public class PrettyJsonWriter
    extends JsonWriter
    JSON Writer that automatically prints prettified JSON based on the inherent structure of the data. This is deliberately kept separate from the default JsonWriter to keep the indention logic away from the default JsonWriter (since it is pretty latency sensitive). Can be used in place of the default JsonWriter, and will print pretty- printed JSON out of the box. Default indentation is from the indented print writer, which is 4 spaces,
    • Constructor Detail

      • PrettyJsonWriter

        public PrettyJsonWriter​(java.io.OutputStream out)
        Create a Prettified JSON writer that writes to the given output stream.
        Parameters:
        out - The stream to write to.
      • PrettyJsonWriter

        public PrettyJsonWriter​(IndentedPrintWriter writer)
        Create a Prettified JSON writer that writes to the given indented print writer.
        Parameters:
        writer - The writer to write to.
    • Method Detail

      • key

        public PrettyJsonWriter key​(boolean key)
        Description copied from class: JsonWriter
        Write the boolean as object key.
        Overrides:
        key in class JsonWriter
        Parameters:
        key - The boolean key.
        Returns:
        The JSON Writer.
      • key

        public PrettyJsonWriter key​(byte key)
        Description copied from class: JsonWriter
        Write the byte as object key.
        Overrides:
        key in class JsonWriter
        Parameters:
        key - The byte key.
        Returns:
        The JSON Writer.
      • key

        public PrettyJsonWriter key​(short key)
        Description copied from class: JsonWriter
        Write the short as object key.
        Overrides:
        key in class JsonWriter
        Parameters:
        key - The short key.
        Returns:
        The JSON Writer.
      • key

        public PrettyJsonWriter key​(int key)
        Description copied from class: JsonWriter
        Write the int as object key.
        Overrides:
        key in class JsonWriter
        Parameters:
        key - The int key.
        Returns:
        The JSON Writer.
      • key

        public PrettyJsonWriter key​(long key)
        Description copied from class: JsonWriter
        Write the long as object key.
        Overrides:
        key in class JsonWriter
        Parameters:
        key - The long key.
        Returns:
        The JSON Writer.
      • key

        public PrettyJsonWriter key​(double key)
        Description copied from class: JsonWriter
        Write the double as object key.
        Overrides:
        key in class JsonWriter
        Parameters:
        key - The double key.
        Returns:
        The JSON Writer.
      • key

        public PrettyJsonWriter key​(java.lang.CharSequence key)
        Description copied from class: JsonWriter
        Write the string as object key.
        Overrides:
        key in class JsonWriter
        Parameters:
        key - The string key.
        Returns:
        The JSON Writer.
      • keyLiteral

        public PrettyJsonWriter keyLiteral​(java.lang.CharSequence key)
        Description copied from class: JsonWriter
        Write the string key without quoting or escaping.
        Overrides:
        keyLiteral in class JsonWriter
        Parameters:
        key - The raw string key.
        Returns:
        The JSON Writer.
      • keyUnescaped

        public PrettyJsonWriter keyUnescaped​(java.lang.CharSequence key)
        Description copied from class: JsonWriter
        Write the string as object key without escaping.
        Overrides:
        keyUnescaped in class JsonWriter
        Parameters:
        key - The string key.
        Returns:
        The JSON Writer.
      • value

        public PrettyJsonWriter value​(boolean value)
        Description copied from class: JsonWriter
        Write boolean value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - The boolean value.
        Returns:
        The JSON Writer.
      • value

        public PrettyJsonWriter value​(byte value)
        Description copied from class: JsonWriter
        Write byte value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - The byte value.
        Returns:
        The JSON Writer.
      • value

        public PrettyJsonWriter value​(short value)
        Description copied from class: JsonWriter
        Write short value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - The short value.
        Returns:
        The JSON Writer.
      • value

        public PrettyJsonWriter value​(int value)
        Description copied from class: JsonWriter
        Write int value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - The int value.
        Returns:
        The JSON Writer.
      • value

        public PrettyJsonWriter value​(long value)
        Description copied from class: JsonWriter
        Write long value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - The long value.
        Returns:
        The JSON Writer.
      • value

        public PrettyJsonWriter value​(double value)
        Description copied from class: JsonWriter
        Write double value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - The double value.
        Returns:
        The JSON Writer.
      • value

        public PrettyJsonWriter value​(java.lang.CharSequence value)
        Description copied from class: JsonWriter
        Write unicode string value.
        Overrides:
        value in class JsonWriter
        Parameters:
        value - The string value.
        Returns:
        The JSON Writer.
      • valueLiteral

        public PrettyJsonWriter valueLiteral​(java.lang.CharSequence value)
        Description copied from class: JsonWriter
        Write a literal string as value. Not quoted and not escaped.
        Overrides:
        valueLiteral in class JsonWriter
        Parameters:
        value - The raw string value.
        Returns:
        The JSON Writer.
      • valueUnescaped

        public PrettyJsonWriter valueUnescaped​(java.lang.CharSequence value)
        Description copied from class: JsonWriter
        Write a string unescaped value.
        Overrides:
        valueUnescaped in class JsonWriter
        Parameters:
        value - The string value.
        Returns:
        The JSON Writer.