Package 

Class JsonStream

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

    
    public final class JsonStream
     implements Closeable, Flushable
                        
    • Constructor Detail

      • JsonStream

        JsonStream(Writer out)
    • Method Detail

      • getIsLenient

         final Boolean getIsLenient()

        Configure this writer to relax its syntax rules. By default, this writer only emits well-formed JSON as specified by RFC 7159. Setting the writer to lenient permits the following:

        Top-level values of any type. With strict writing, the top-level value must be an object or an array. Numbers may be Double.isNaN or Double.isInfinite.

      • setIsLenient

         final Unit setIsLenient(Boolean isLenient)

        Configure this writer to relax its syntax rules. By default, this writer only emits well-formed JSON as specified by RFC 7159. Setting the writer to lenient permits the following:

        Top-level values of any type. With strict writing, the top-level value must be an object or an array. Numbers may be Double.isNaN or Double.isInfinite.

      • getIsHtmlSafe

         final Boolean getIsHtmlSafe()

        Configure this writer to emit JSON that's safe for direct inclusion in HTML and XML documents. This escapes the HTML characters <, >, & and = before writing them to the stream. Without this setting, your XML/HTML encoder should replace these characters with the corresponding escape sequences.

      • setIsHtmlSafe

         final Unit setIsHtmlSafe(Boolean isHtmlSafe)

        Configure this writer to emit JSON that's safe for direct inclusion in HTML and XML documents. This escapes the HTML characters <, >, & and = before writing them to the stream. Without this setting, your XML/HTML encoder should replace these characters with the corresponding escape sequences.

      • setIndent

         final Unit setIndent(String indent)

        Sets the indentation string to be repeated for each level of indentation in the encoded document. If indent.isEmpty() the encoded document will be compact. Otherwise the encoded document will be more human-readable.

        Parameters:
        indent - a string containing only whitespace.
      • beginArray

         final JsonStream beginArray()

        Begins encoding a new array. Each call to this method must be paired with a call to .endArray.

      • beginObject

         final JsonStream beginObject()

        Begins encoding a new object. Each call to this method must be paired with a call to .endObject.

      • close

         Unit close()

        Flushes and closes this writer and the underlying Writer.

      • name

         final JsonStream name(String name)

        Encodes the property name.

        Parameters:
        name - the name of the forthcoming value.
      • value

         final JsonStream value(String value)

        Encodes value.

        Parameters:
        value - the literal string value, or null to encode a null literal.
      • value

         final JsonStream value(Object obj, Boolean shouldRedactKeys)

        Serialises an arbitrary object as JSON, handling primitive types as well as Collections, Maps, and arrays.

      • value

         final JsonStream value(Object obj)

        Serialises an arbitrary object as JSON, handling primitive types as well as Collections, Maps, and arrays.

      • jsonValue

         final JsonStream jsonValue(String value)

        Writes value directly to the writer without quoting or escaping.

        Parameters:
        value - the literal string value, or null to encode a null literal.
      • flush

         Unit flush()

        Ensures all buffered data is written to the underlying Writer and flushes that writer.