package serde

import "github.com/aws/smithy-go/document/internal/serde"

Index

Variables

var ReflectTypeOf = struct {
	BigFloat             reflect.Type
	BigInt               reflect.Type
	DocumentNumber       reflect.Type
	MapStringToInterface reflect.Type
	Time                 reflect.Type
}{
	BigFloat:             reflect.TypeOf((*big.Float)(nil)).Elem(),
	BigInt:               reflect.TypeOf((*big.Int)(nil)).Elem(),
	DocumentNumber:       reflect.TypeOf((*document.Number)(nil)).Elem(),
	MapStringToInterface: reflect.TypeOf((map[string]interface{})(nil)),
	Time:                 reflect.TypeOf((*time.Time)(nil)).Elem(),
}

ReflectTypeOf is a structure containing various reflect.Type members that are useful to document Marshaler or Unmarshaler implementations.

Functions

func DecoderFieldByIndex

func DecoderFieldByIndex(v reflect.Value, index []int) reflect.Value

DecoderFieldByIndex finds the field with the provided nested index, allocating embedded parent structs if needed

func EncoderFieldByIndex

func EncoderFieldByIndex(v reflect.Value, index []int) (reflect.Value, bool)

EncoderFieldByIndex finds the field with the provided nested index

func Indirect

func Indirect(v reflect.Value, decodingNull bool) reflect.Value

Indirect will walk a value's interface or pointer value types. Returning the final value or the value a unmarshaler is defined on.

Based on the enoding/json type reflect value type indirection in Go Stdlib https://golang.org/src/encoding/json/decode.go Indirect func.

func IsZeroValue

func IsZeroValue(v reflect.Value) bool

IsZeroValue returns whether v is the zero-value for its type.

func PtrToValue

func PtrToValue(in interface{}) interface{}

PtrToValue given the input value will dereference pointers and returning the element pointed to.

func ValueElem

func ValueElem(v reflect.Value) reflect.Value

ValueElem walks interface and pointer types and returns the underlying element.

Types

type CachedFields

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

CachedFields is a cache entry for a type's fields.

func GetStructFields

func GetStructFields(t reflect.Type) *CachedFields

GetStructFields returns a list of fields for the given type. Type info is cached to avoid repeated calls into the reflect package

func (*CachedFields) All

func (f *CachedFields) All() []Field

All returns all the fields for the cached type.

func (*CachedFields) FieldByName

func (f *CachedFields) FieldByName(name string) (Field, bool)

FieldByName retrieves a field by name.

type Field

type Field struct {
	Tag

	Name        string
	NameFromTag bool

	Index []int
	Type  reflect.Type
}

Field is represents a struct field, tag, type, and index.

type Tag

type Tag struct {
	Name      string
	Ignore    bool
	OmitEmpty bool
}

Tag represents the `document` struct field tag and associated options

func ParseTag

func ParseTag(tagStr string) (tag Tag)

ParseTag splits a struct field tag into its name and comma-separated options.

Source Files

field.go field_cache.go reflect.go serde.go tags.go

Version
v1.22.3 (latest)
Published
Feb 17, 2025
Platform
js/wasm
Imports
7 packages
Last checked
3 weeks ago

Tools for package owners.