marshal

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	NameTransform func(path []string, field string) string
	Exclude       func(path []string, field string) bool
	// contains filtered or unexported fields
}

Engine marshals values with transform/exclusion hooks.

func New

func New(nameTransform func(path []string, field string) string, exclude func(path []string, field string) bool, omitEmpty bool, nilSliceNull bool, timeLayout string, caseKey string, compileName func(string) string) *Engine

func (*Engine) ExcludeFields added in v0.10.0

func (e *Engine) ExcludeFields(t reflect.Type, paths []string) error

ExcludeFields compiles canonical Go-field paths through existing serializer plans, so aliases/casing/inline holders use the same output names as Marshal. Configure the engine before publishing or invoking it.

func (*Engine) Marshal

func (e *Engine) Marshal(value interface{}) ([]byte, error)

func (*Engine) MarshalPtr

func (e *Engine) MarshalPtr(value interface{}) ([]byte, error)

MarshalPtr marshals pointer roots on the fast pointer path.

func (*Engine) MarshalPtrTo

func (e *Engine) MarshalPtrTo(dst []byte, value interface{}) ([]byte, error)

MarshalPtrTo appends pointer-root marshaled JSON to dst.

func (*Engine) MarshalTo

func (e *Engine) MarshalTo(dst []byte, value interface{}) ([]byte, error)

MarshalTo appends marshaled JSON to dst and returns the resulting slice.

func (*Engine) MarshalTypedPtr

func (e *Engine) MarshalTypedPtr(dst []byte, elemType reflect.Type, ptr unsafe.Pointer) ([]byte, error)

MarshalTypedPtr appends a typed pointer-root value to dst. This is intended for internal fast paths where caller already has root type and pointer.

func (*Engine) Wire added in v0.10.0

func (e *Engine) Wire(t reflect.Type) (*WireShape, error)

Wire projects existing plans and hooks without sampling any output values.

type Standard added in v0.10.0

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

Standard describes encoding/json v1 output. It never encodes values and does not reuse the transformed engine's field, omission or inline policy.

func NewStandard added in v0.10.0

func NewStandard(t reflect.Type) *Standard

func (*Standard) Wire added in v0.10.0

func (s *Standard) Wire() (*WireShape, error)

type StandardEncoder added in v0.10.0

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

StandardEncoder projects typed objects without a JSON roundtrip. Scalar, opaque custom and map values are delegated to encoding/json. Object field authority is x/shape.JSONFields, including JSON-specific promotion dominance.

func NewStandardEncoder added in v0.10.0

func NewStandardEncoder(exclude func([]string, string) bool, excludeIndex func([]string, []int) bool) *StandardEncoder

func (*StandardEncoder) Marshal added in v0.10.0

func (e *StandardEncoder) Marshal(value any) ([]byte, error)

type WireProperty added in v0.10.0

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

func (WireProperty) Field added in v0.10.0

func (p WireProperty) Field() reflect.StructField

Field returns provenance indexed from the containing WireShape.Source, including anonymous/inline ancestors. Returned indexes are detached.

func (WireProperty) Name added in v0.10.0

func (p WireProperty) Name() string

func (WireProperty) Required added in v0.10.0

func (p WireProperty) Required() bool

func (WireProperty) Shape added in v0.10.0

func (p WireProperty) Shape() *WireShape

type WireShape added in v0.10.0

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

WireShape is immutable JSON metadata from this engine's actual field plans. It is neither a Go type builder nor a schema dialect.

func (*WireShape) Element added in v0.10.0

func (s *WireShape) Element() *WireShape

func (*WireShape) Format added in v0.10.0

func (s *WireShape) Format() string

func (*WireShape) Kind added in v0.10.0

func (s *WireShape) Kind() reflect.Kind

func (*WireShape) Length added in v0.10.0

func (s *WireShape) Length() int

func (*WireShape) Nullable added in v0.10.0

func (s *WireShape) Nullable() bool

func (*WireShape) Properties added in v0.10.0

func (s *WireShape) Properties() []WireProperty

func (*WireShape) Source added in v0.10.0

func (s *WireShape) Source() reflect.Type

Jump to

Keyboard shortcuts

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