public abstract class JsonOutputStream
extends java.lang.Object
Abstract base class for JSON output streams.
| Constructor and Description |
|---|
JsonOutputStream() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
clear()
Clear the output stream.
|
abstract int |
length()
Return the number of characters written.
|
abstract java.lang.String |
toString()
Return the output in JSON format.
|
static JsonOutputStream |
withBuffer()
Return a new JSON output stream which writes to an in-memory buffer.
|
abstract void |
writeChar(char c)
Write a character to the stream.
|
void |
writeElement(JsonElement element)
Write a JSON element (null, boolean, number, string, array, object) to the stream.
|
void |
writeString(java.lang.String text)
Write the characters of a string to the stream, with surrounding quotes and escape sequences (as appropriate).
|
void |
writeVerbatim(java.lang.String text)
Write the characters of a string to the stream, without surrounding quotes.
|
public abstract void clear()
Clear the output stream.
public abstract int length()
Return the number of characters written.
public abstract java.lang.String toString()
Return the output in JSON format.
toString in class java.lang.Objectpublic static JsonOutputStream withBuffer()
Return a new JSON output stream which writes to an in-memory buffer.
public abstract void writeChar(char c)
Write a character to the stream.
c - Character to write.public void writeElement(JsonElement element)
Write a JSON element (null, boolean, number, string, array, object) to the stream.
element - (nullable) Element to write.public void writeString(java.lang.String text)
Write the characters of a string to the stream, with surrounding quotes and escape sequences (as appropriate).
text - String to write.public void writeVerbatim(java.lang.String text)
Write the characters of a string to the stream, without surrounding quotes.
text - String to write.