unpack

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package unpack provides a means to unmarshal Go values that have embedded interface values. Different concrete implementations of any interface value are properly decoded using an `unpack` struct tag to indicate a JSON field identifying the desired concrete type. To do so, a client of unpack registers each potential type in a Reflector, which binds a field with a particular value to that type.

Index

Constants

This section is empty.

Variables

View Source
var ErrSkip = errors.New("unpack skip tag can only appear once")

Functions

This section is empty.

Types

type Reflector

type Reflector map[string]map[string]reflect.Type

func New

func New(templates ...interface{}) Reflector

func (Reflector) Add

func (r Reflector) Add(template interface{}) Reflector

func (Reflector) AddAs

func (r Reflector) AddAs(template interface{}, as string) Reflector

AddAs is like Add but as overrides any name stored under the "unpack" key in template's field tags.

func (Reflector) Unmarshal

func (r Reflector) Unmarshal(b []byte, result interface{}) error

func (Reflector) UnmarshalObject

func (r Reflector) UnmarshalObject(object interface{}, result interface{}) error

Jump to

Keyboard shortcuts

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