json

package
v1.27.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveProtocolErrorType

func ResolveProtocolErrorType(headerType string, bodyInfo ProtocolErrorInfo) (string, bool)

ResolveProtocolErrorType resolves the error type from the header value and body info, returning the type and whether one was found.

func SanitizeErrorCode

func SanitizeErrorCode(code string) string

SanitizeErrorCode strips namespace prefixes and URI suffixes from error codes received on the wire.

Types

type Options

type Options struct {
	// Controls whether the @jsonName trait is used to determine JSON object
	// keys. If false (the default), the member name is used as-is.
	UseJSONName bool
}

Options configures JSON shape serialization and deserialization.

type ProtocolErrorInfo

type ProtocolErrorInfo struct {
	Type    string `json:"__type"`
	Message string

	// nonstandard, but some AWS services do present the type here
	Code any
}

ProtocolErrorInfo holds the error type and message decoded from a JSON error response body.

func GetProtocolErrorInfo

func GetProtocolErrorInfo(decoder *json.Decoder) (ProtocolErrorInfo, error)

GetProtocolErrorInfo decodes error type/message from a JSON response body.

type ShapeDeserializer

type ShapeDeserializer struct {
	// contains filtered or unexported fields
}

ShapeDeserializer implements unmarshaling of JSON into Smithy shapes.

func NewShapeDeserializer

func NewShapeDeserializer(p []byte, opts ...func(*Options)) *ShapeDeserializer

NewShapeDeserializer creates a new ShapeDeserializer.

func (*ShapeDeserializer) Close

func (d *ShapeDeserializer) Close()

Close returns the deserializer to the pool for reuse.

func (*ShapeDeserializer) DirectReadList

func (d *ShapeDeserializer) DirectReadList(schema *smithy.Schema, memberFn func() error) error

DirectReadList is a concrete-type fast path that avoids interface dispatch. It skips the head stack and reads list elements directly using peek.

func (*ShapeDeserializer) DirectReadMap

func (d *ShapeDeserializer) DirectReadMap(schema *smithy.Schema, memberFn func(string) error) error

DirectReadMap is a concrete-type fast path that avoids interface dispatch. It skips the head stack and reads map entries directly.

func (*ShapeDeserializer) DirectReadStruct

func (d *ShapeDeserializer) DirectReadStruct(schema *smithy.Schema, memberFn func(*smithy.Schema) error) error

DirectReadStruct is a concrete-type fast path that avoids interface dispatch. It skips the head stack and reads struct members directly.

func (*ShapeDeserializer) DirectReadUnion

func (d *ShapeDeserializer) DirectReadUnion(schema *smithy.Schema, memberFn func(*smithy.Schema) error) error

DirectReadUnion is a concrete-type fast path that avoids interface dispatch. It opens the union object, finds the single non-null member, calls memberFn, then drains to the closing brace.

func (*ShapeDeserializer) ReadBigFloat

func (d *ShapeDeserializer) ReadBigFloat(_ *smithy.Schema, _ *big.Float) error

ReadBigFloat is unimplemented and will return an error.

func (*ShapeDeserializer) ReadBigInt

func (d *ShapeDeserializer) ReadBigInt(_ *smithy.Schema, _ *big.Int) error

ReadBigInt is unimplemented and will return an error.

func (*ShapeDeserializer) ReadBlob

func (d *ShapeDeserializer) ReadBlob(s *smithy.Schema, v *[]byte) error

ReadBlob implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadBool

func (d *ShapeDeserializer) ReadBool(s *smithy.Schema, v *bool) error

ReadBool implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadDocument

func (d *ShapeDeserializer) ReadDocument(schema *smithy.Schema, v *document.Value) error

ReadDocument reads a JSON value into a document Value.

func (*ShapeDeserializer) ReadFloat32

func (d *ShapeDeserializer) ReadFloat32(s *smithy.Schema, v *float32) error

ReadFloat32 implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadFloat64

func (d *ShapeDeserializer) ReadFloat64(s *smithy.Schema, v *float64) error

ReadFloat64 implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadInt8

func (d *ShapeDeserializer) ReadInt8(s *smithy.Schema, v *int8) error

ReadInt8 implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadInt16

func (d *ShapeDeserializer) ReadInt16(s *smithy.Schema, v *int16) error

ReadInt16 implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadInt32

func (d *ShapeDeserializer) ReadInt32(s *smithy.Schema, v *int32) error

ReadInt32 implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadInt64

func (d *ShapeDeserializer) ReadInt64(s *smithy.Schema, v *int64) error

ReadInt64 implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadList

func (d *ShapeDeserializer) ReadList(s *smithy.Schema) error

ReadList implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadListItem

func (d *ShapeDeserializer) ReadListItem(s *smithy.Schema) (bool, error)

ReadListItem implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadMap

func (d *ShapeDeserializer) ReadMap(s *smithy.Schema) error

ReadMap implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadMapKey

func (d *ShapeDeserializer) ReadMapKey(s *smithy.Schema) (string, bool, error)

ReadMapKey implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadNil

func (d *ShapeDeserializer) ReadNil(s *smithy.Schema) (bool, error)

ReadNil implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadString

func (d *ShapeDeserializer) ReadString(s *smithy.Schema, v *string) error

ReadString implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadStruct

func (d *ShapeDeserializer) ReadStruct(s *smithy.Schema) error

ReadStruct implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadStructMember

func (d *ShapeDeserializer) ReadStructMember() (*smithy.Schema, error)

ReadStructMember implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadTime

func (d *ShapeDeserializer) ReadTime(schema *smithy.Schema, v *time.Time) error

ReadTime implements smithy.ShapeDeserializer.

func (*ShapeDeserializer) ReadUnion

func (d *ShapeDeserializer) ReadUnion(s *smithy.Schema) (*smithy.Schema, error)

ReadUnion implements smithy.ShapeDeserializer.

type ShapeSerializer

type ShapeSerializer struct {
	// contains filtered or unexported fields
}

ShapeSerializer implements marshaling of Smithy shapes to JSON. It writes directly to a []byte buffer without intermediate allocations.

func NewShapeSerializer

func NewShapeSerializer(opts ...func(*Options)) *ShapeSerializer

NewShapeSerializer creates a new ShapeSerializer.

func (*ShapeSerializer) Bytes

func (s *ShapeSerializer) Bytes() []byte

Bytes returns a copy of the serialized JSON bytes, safe to retain after Close().

func (*ShapeSerializer) Close

func (s *ShapeSerializer) Close()

Close returns the serializer to the pool for reuse.

func (*ShapeSerializer) CloseList

func (s *ShapeSerializer) CloseList()

CloseList implements smithy.ShapeSerializer.

func (*ShapeSerializer) CloseMap

func (s *ShapeSerializer) CloseMap()

CloseMap implements smithy.ShapeSerializer.

func (*ShapeSerializer) CloseStruct

func (s *ShapeSerializer) CloseStruct()

CloseStruct implements smithy.ShapeSerializer.

func (*ShapeSerializer) CloseUnion

func (s *ShapeSerializer) CloseUnion()

CloseUnion implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteBigFloat

func (s *ShapeSerializer) WriteBigFloat(_ *smithy.Schema, _ *big.Float)

WriteBigFloat is unimplemented and will panic.

func (*ShapeSerializer) WriteBigInt

func (s *ShapeSerializer) WriteBigInt(_ *smithy.Schema, _ *big.Int)

WriteBigInt is unimplemented and will panic.

func (*ShapeSerializer) WriteBlob

func (s *ShapeSerializer) WriteBlob(schema *smithy.Schema, v []byte)

WriteBlob implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteBool

func (s *ShapeSerializer) WriteBool(schema *smithy.Schema, v bool)

WriteBool implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteDocument

func (s *ShapeSerializer) WriteDocument(schema *smithy.Schema, v document.Value)

WriteDocument writes a document value to JSON.

func (*ShapeSerializer) WriteFloat32

func (s *ShapeSerializer) WriteFloat32(schema *smithy.Schema, v float32)

WriteFloat32 implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteFloat64

func (s *ShapeSerializer) WriteFloat64(schema *smithy.Schema, v float64)

WriteFloat64 implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteInt8

func (s *ShapeSerializer) WriteInt8(schema *smithy.Schema, v int8)

WriteInt8 implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteInt16

func (s *ShapeSerializer) WriteInt16(schema *smithy.Schema, v int16)

WriteInt16 implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteInt32

func (s *ShapeSerializer) WriteInt32(schema *smithy.Schema, v int32)

WriteInt32 implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteInt64

func (s *ShapeSerializer) WriteInt64(schema *smithy.Schema, v int64)

WriteInt64 implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteKey

func (s *ShapeSerializer) WriteKey(_ *smithy.Schema, key string)

WriteKey implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteList

func (s *ShapeSerializer) WriteList(schema *smithy.Schema)

WriteList implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteMap

func (s *ShapeSerializer) WriteMap(schema *smithy.Schema)

WriteMap implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteNil

func (s *ShapeSerializer) WriteNil(schema *smithy.Schema)

WriteNil implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteString

func (s *ShapeSerializer) WriteString(schema *smithy.Schema, v string)

WriteString implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteStruct

func (s *ShapeSerializer) WriteStruct(schema *smithy.Schema)

WriteStruct implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteTime

func (s *ShapeSerializer) WriteTime(schema *smithy.Schema, v time.Time)

WriteTime implements smithy.ShapeSerializer.

func (*ShapeSerializer) WriteUnion

func (s *ShapeSerializer) WriteUnion(schema, variant *smithy.Schema)

WriteUnion implements smithy.ShapeSerializer.

Directories

Path Synopsis
internal
stdlib
Package stdlib contains code copied from the Go standard library's encoding/json package (Go 1.24).
Package stdlib contains code copied from the Go standard library's encoding/json package (Go 1.24).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL