Class JsonWriter
java.lang.Object
software.amazon.awssdk.protocols.jsoncore.JsonWriter
- All Implemented Interfaces:
AutoCloseable
,SdkAutoCloseable
Thin wrapper around Jackson's JSON generator.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A builder for configuring and creatingJsonWriter
.static class
Indicates an issue writing JSON content.static interface
Generate aJsonGenerator
for aOutputStream
. -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonWriter.Builder
builder()
void
close()
Closes the generator and flushes to write.static JsonWriter
create()
byte[]
getBytes()
Get the JSON content as a UTF-8 encoded byte array.writeFieldName
(String fieldName) writeNumber
(String number) writeValue
(boolean bool) writeValue
(double val) writeValue
(float val) writeValue
(int val) writeValue
(long val) writeValue
(short val) writeValue
(String val) writeValue
(BigDecimal value) writeValue
(BigInteger value) writeValue
(ByteBuffer bytes) writeValue
(Instant instant)
-
Method Details
-
create
-
builder
-
writeStartArray
-
writeEndArray
-
writeNull
-
writeStartObject
-
writeEndObject
-
writeFieldName
-
writeValue
-
writeValue
-
writeValue
-
writeValue
-
writeValue
-
writeValue
-
writeValue
-
writeValue
-
writeValue
-
writeValue
-
writeValue
-
writeNumber
-
close
public void close()Closes the generator and flushes to write. Must be called when finished writing JSON content.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSdkAutoCloseable
-
getBytes
public byte[] getBytes()Get the JSON content as a UTF-8 encoded byte array. It is recommended to hold onto the array reference rather then making repeated calls to this method as a new array will be created each time.- Returns:
- Array of UTF-8 encoded bytes that make up the generated JSON.
-