Package io.avaje.jsonb.stream
Class JsonStream
- java.lang.Object
-
- io.avaje.jsonb.stream.JsonStream
-
- All Implemented Interfaces:
JsonStreamAdapter
public final class JsonStream extends Object implements JsonStreamAdapter
Default implementation of JsonStreamAdapter provided with Jsonb.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JsonStream.Builder
Used to build JsonStream with custom settings.
-
Constructor Summary
Constructors Constructor Description JsonStream()
Create with the given default configuration.JsonStream(boolean serializeNulls, boolean serializeEmpty, boolean failOnUnknown)
Create additionally providing the jsonFactory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BufferedJsonWriter
bufferedWriter()
Return a JsonWriter for use for writing to json string.BytesJsonWriter
bufferedWriterAsBytes()
Return a JsonWriter to use for writing json to byte array.static JsonStream.Builder
builder()
Return a new builder to create a JsonStream with custom configuration.PropertyNames
properties(String... names)
Return PropertyNames given the names of properties.JsonReader
reader(byte[] json)
Return the JsonReader given json content as bytes.JsonReader
reader(InputStream inputStream)
Return the JsonReader given json string content.JsonReader
reader(Reader reader)
Return the JsonReader given json string content.JsonReader
reader(String json)
Return the JsonReader given json string content.JsonWriter
writer(OutputStream outputStream)
Return the JsonWriter given the outputStream.JsonWriter
writer(Writer writer)
Return the JsonWriter given writer to use.
-
-
-
Method Detail
-
builder
public static JsonStream.Builder builder()
Return a new builder to create a JsonStream with custom configuration.var jsonStream = JsonStream.builder() .serializeNulls(true) .build();
-
properties
public PropertyNames properties(String... names)
Description copied from interface:JsonStreamAdapter
Return PropertyNames given the names of properties.The PropertyNames can prepare the names for writing such as escaping quotes and encoding to bytes so that the names can be written more efficiently.
- Specified by:
properties
in interfaceJsonStreamAdapter
- See Also:
JsonWriter.names(PropertyNames)
,JsonWriter.name(int)
-
reader
public JsonReader reader(String json)
Description copied from interface:JsonStreamAdapter
Return the JsonReader given json string content.- Specified by:
reader
in interfaceJsonStreamAdapter
-
reader
public JsonReader reader(byte[] json)
Description copied from interface:JsonStreamAdapter
Return the JsonReader given json content as bytes.- Specified by:
reader
in interfaceJsonStreamAdapter
-
reader
public JsonReader reader(Reader reader)
Description copied from interface:JsonStreamAdapter
Return the JsonReader given json string content.- Specified by:
reader
in interfaceJsonStreamAdapter
-
reader
public JsonReader reader(InputStream inputStream)
Description copied from interface:JsonStreamAdapter
Return the JsonReader given json string content.- Specified by:
reader
in interfaceJsonStreamAdapter
-
writer
public JsonWriter writer(Writer writer)
Description copied from interface:JsonStreamAdapter
Return the JsonWriter given writer to use.- Specified by:
writer
in interfaceJsonStreamAdapter
-
writer
public JsonWriter writer(OutputStream outputStream)
Description copied from interface:JsonStreamAdapter
Return the JsonWriter given the outputStream.- Specified by:
writer
in interfaceJsonStreamAdapter
-
bufferedWriter
public BufferedJsonWriter bufferedWriter()
Description copied from interface:JsonStreamAdapter
Return a JsonWriter for use for writing to json string.- Specified by:
bufferedWriter
in interfaceJsonStreamAdapter
-
bufferedWriterAsBytes
public BytesJsonWriter bufferedWriterAsBytes()
Description copied from interface:JsonStreamAdapter
Return a JsonWriter to use for writing json to byte array.- Specified by:
bufferedWriterAsBytes
in interfaceJsonStreamAdapter
-
-