public static final class JsonWriter.JsonWriterContext
extends java.lang.Object
JsonWriter.| Modifier and Type | Method and Description |
|---|---|
JsonAppendableWriter |
on(java.lang.Appendable appendable)
Creates a
JsonAppendableWriter that can output to an
Appendable subclass, such as a StringBuilder, a
Writer a PrintStream or a CharBuffer. |
JsonAppendableWriter |
on(java.io.OutputStream out)
Creates a
JsonAppendableWriter that can output to an OutputStream subclass. |
JsonAppendableWriter |
on(java.io.PrintStream appendable)
Creates a
JsonAppendableWriter that can output to an PrintStream subclass. |
JsonStringWriter |
string()
Creates a new
JsonStringWriter. |
public JsonStringWriter string()
JsonStringWriter.
String json = JsonWriter.indent(" ").string()
.object()
.array("a")
.value(1)
.value(2)
.end()
.value("b", false)
.value("c", true)
.end()
.done();
public JsonAppendableWriter on(java.lang.Appendable appendable)
JsonAppendableWriter that can output to an
Appendable subclass, such as a StringBuilder, a
Writer a PrintStream or a CharBuffer.public JsonAppendableWriter on(java.io.PrintStream appendable)
JsonAppendableWriter that can output to an PrintStream subclass.
JsonWriter.indent(" ").on(System.out)
.object()
.value("a", 1)
.value("b", 2)
.end()
.done();
public JsonAppendableWriter on(java.io.OutputStream out)
JsonAppendableWriter that can output to an OutputStream subclass. Uses the UTF-8
Charset. To specify a different charset, use the JsonWriter.on(Appendable) method with an
OutputStreamWriter.
JsonWriter.indent(" ").on(System.out)
.object()
.value("a", 1)
.value("b", 2)
.end()
.done();