Documentation
¶
Index ¶
- func Marshal(value interface{}) ([]byte, error)
- func MarshalRoot(value interface{}) ([]byte, error)
- func Port(from any, to any) error
- func RegisterUnion(typ reflect.Type, discriminator string, variants ...UnionVariant)
- func Unmarshal(raw []byte, to any) error
- func UnmarshalRoot(raw []byte, to any) error
- type Field
- type UnionUnmarshaler
- type UnionVariant
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalRoot ¶
func RegisterUnion ¶
func RegisterUnion(typ reflect.Type, discriminator string, variants ...UnionVariant)
func Unmarshal ¶
Unmarshal is similar to encoding/json.Unmarshal and parses the JSON-encoded data and stores it in the given pointer.
func UnmarshalRoot ¶
UnmarshalRoot is like Unmarshal, but doesn't try to call MarshalJSON on the root element. Useful if a struct's UnmarshalJSON is overrode to use the behavior of this encoder versus the standard library.
Types ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
type UnionUnmarshaler ¶ added in v1.17.0
type UnionUnmarshaler[T any] struct { Value T }
Useful to wrap a union type to force it to use apijson.UnmarshalJSON since you cannot define an UnmarshalJSON function on the interface itself.
func (*UnionUnmarshaler[T]) UnmarshalJSON ¶ added in v1.17.0
func (c *UnionUnmarshaler[T]) UnmarshalJSON(buf []byte) error
Click to show internal directories.
Click to hide internal directories.