Documentation ¶
Index ¶
- func Deref(t reflect.Type) reflect.Type
- func Marshal(val any) (map[string]map[string]any, error)
- func Repr(v any) string
- func SetMapIndexValue(tp reflect.Type, value, key, target reflect.Value)
- func SetValue(tp reflect.Type, value, target reflect.Value)
- func UnmarshalJsonBytes(content []byte, v any, opts ...UnmarshalOption) error
- func UnmarshalJsonMap(m map[string]any, v any, opts ...UnmarshalOption) error
- func UnmarshalJsonReader(reader io.Reader, v any, opts ...UnmarshalOption) error
- func UnmarshalKey(m map[string]any, v any) error
- func UnmarshalTomlBytes(content []byte, v any, opts ...UnmarshalOption) error
- func UnmarshalTomlReader(r io.Reader, v any, opts ...UnmarshalOption) error
- func UnmarshalYamlBytes(content []byte, v any, opts ...UnmarshalOption) error
- func UnmarshalYamlReader(reader io.Reader, v any, opts ...UnmarshalOption) error
- func ValidatePtr(v reflect.Value) error
- type UnmarshalOption
- type Unmarshaler
- type Valuer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶ added in v1.3.3
Marshal marshals the given val and returns the map that contains the fields. optional=another is not implemented, and it's hard to implement and not commonly used.
func SetMapIndexValue ¶ added in v1.4.4
SetMapIndexValue sets target to value at key position, pointers are processed automatically.
func SetValue ¶ added in v1.4.4
SetValue sets target to value, pointers are processed automatically.
func UnmarshalJsonBytes ¶
func UnmarshalJsonBytes(content []byte, v any, opts ...UnmarshalOption) error
UnmarshalJsonBytes unmarshals content into v.
func UnmarshalJsonMap ¶
func UnmarshalJsonMap(m map[string]any, v any, opts ...UnmarshalOption) error
UnmarshalJsonMap unmarshals content from m into v.
func UnmarshalJsonReader ¶
func UnmarshalJsonReader(reader io.Reader, v any, opts ...UnmarshalOption) error
UnmarshalJsonReader unmarshals content from reader into v.
func UnmarshalKey ¶
UnmarshalKey unmarshals m into v with the tag key.
func UnmarshalTomlBytes ¶ added in v1.3.4
func UnmarshalTomlBytes(content []byte, v any, opts ...UnmarshalOption) error
UnmarshalTomlBytes unmarshals TOML bytes into the given v.
func UnmarshalTomlReader ¶ added in v1.3.4
func UnmarshalTomlReader(r io.Reader, v any, opts ...UnmarshalOption) error
UnmarshalTomlReader unmarshals TOML from the given io.Reader into the given v.
func UnmarshalYamlBytes ¶
func UnmarshalYamlBytes(content []byte, v any, opts ...UnmarshalOption) error
UnmarshalYamlBytes unmarshals content into v.
func UnmarshalYamlReader ¶
func UnmarshalYamlReader(reader io.Reader, v any, opts ...UnmarshalOption) error
UnmarshalYamlReader unmarshals content from reader into v.
func ValidatePtr ¶
ValidatePtr validates v if it's a valid pointer.
Types ¶
type UnmarshalOption ¶
type UnmarshalOption func(*unmarshalOptions)
UnmarshalOption defines the method to customize an Unmarshaler.
func WithCanonicalKeyFunc ¶
func WithCanonicalKeyFunc(f func(string) string) UnmarshalOption
WithCanonicalKeyFunc customizes an Unmarshaler with Canonical Key func.
func WithDefault ¶ added in v1.4.5
func WithDefault() UnmarshalOption
WithDefault customizes an Unmarshaler with fill default values.
func WithOpaqueKeys ¶ added in v1.5.5
func WithOpaqueKeys() UnmarshalOption
WithOpaqueKeys customizes an Unmarshaler with opaque keys. Opaque keys are keys that are not processed by the unmarshaler.
func WithStringValues ¶
func WithStringValues() UnmarshalOption
WithStringValues customizes an Unmarshaler with number values from strings.
type Unmarshaler ¶
type Unmarshaler struct {
// contains filtered or unexported fields
}
Unmarshaler is used to unmarshal with the given tag key.
func NewUnmarshaler ¶
func NewUnmarshaler(key string, opts ...UnmarshalOption) *Unmarshaler
NewUnmarshaler returns an Unmarshaler.
func (*Unmarshaler) Unmarshal ¶
func (u *Unmarshaler) Unmarshal(i, v any) error
Unmarshal unmarshals m into v.
func (*Unmarshaler) UnmarshalValuer ¶
func (u *Unmarshaler) UnmarshalValuer(m Valuer, v any) error
UnmarshalValuer unmarshals m into v.