Class SdkJsonGenerator
java.lang.Object
software.amazon.awssdk.protocols.json.SdkJsonGenerator
- All Implemented Interfaces:
StructuredJsonGenerator
- Direct Known Subclasses:
SdkCborGenerator,SdkRpcV2CborGenerator
Thin wrapper around Jackson's JSON generator.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classIndicates an issue writing JSON content. -
Field Summary
Fields inherited from interface software.amazon.awssdk.protocols.json.StructuredJsonGenerator
NO_OP -
Constructor Summary
ConstructorsConstructorDescriptionSdkJsonGenerator(software.amazon.awssdk.thirdparty.jackson.core.JsonFactory factory, String contentType) -
Method Summary
Modifier and TypeMethodDescriptionintReturns the size of the generated content in bytes without copying.Returns aContentStreamProviderthat streams directly from the internal buffers without creating a contiguous copy.byte[]getBytes()Get the JSON content as a UTF-8 encoded byte array.New clients use.invalid reference
SdkJsonProtocolFactory#getContentType()writeBinaryValue(byte[] bytes) Writes binary data directly from a byte array, avoiding the overhead of wrapping in aByteBuffer.writeFieldName(String fieldName) writeNumber(String number) writeValue(boolean bool) writeValue(byte val) 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) Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.awssdk.protocols.json.StructuredJsonGenerator
writeStartArray
-
Constructor Details
-
SdkJsonGenerator
public SdkJsonGenerator(software.amazon.awssdk.thirdparty.jackson.core.JsonFactory factory, String contentType)
-
-
Method Details
-
writeStartArray
- Specified by:
writeStartArrayin interfaceStructuredJsonGenerator
-
writeEndArray
- Specified by:
writeEndArrayin interfaceStructuredJsonGenerator
-
writeNull
- Specified by:
writeNullin interfaceStructuredJsonGenerator
-
writeStartObject
- Specified by:
writeStartObjectin interfaceStructuredJsonGenerator
-
writeEndObject
- Specified by:
writeEndObjectin interfaceStructuredJsonGenerator
-
writeFieldName
- Specified by:
writeFieldNamein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeBinaryValue
Description copied from interface:StructuredJsonGeneratorWrites binary data directly from a byte array, avoiding the overhead of wrapping in aByteBuffer. The default implementation wraps the array and delegates toStructuredJsonGenerator.writeValue(ByteBuffer).- Specified by:
writeBinaryValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeValue
- Specified by:
writeValuein interfaceStructuredJsonGenerator
-
writeNumber
- Specified by:
writeNumberin interfaceStructuredJsonGenerator
-
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.- Specified by:
getBytesin interfaceStructuredJsonGenerator- Returns:
- Array of UTF-8 encoded bytes that make up the generated JSON.
-
contentSize
public int contentSize()Returns the size of the generated content in bytes without copying.- Specified by:
contentSizein interfaceStructuredJsonGenerator
-
contentStreamProvider
Returns aContentStreamProviderthat streams directly from the internal buffers without creating a contiguous copy. For small payloads this wraps the single base buffer; for large payloads it chains the base buffer and overflow chunks.- Specified by:
contentStreamProviderin interfaceStructuredJsonGenerator- Returns:
- a content stream provider, or
nullifStructuredJsonGenerator.getBytes()returns null
-
getContentType
Description copied from interface:StructuredJsonGeneratorNew clients use.invalid reference
SdkJsonProtocolFactory#getContentType()- Specified by:
getContentTypein interfaceStructuredJsonGenerator
-