Documentation
¶
Index ¶
- func Marshal(value interface{}) ([]byte, error)
- func MarshalRoot(value interface{}) ([]byte, error)
- func Port(from any, to any) error
- func RegisterDiscriminatedUnion[T any](key string, mappings map[string]reflect.Type)
- func RegisterFieldValidator[T any, V string | bool | int](fieldName string, nullable bool, values ...V)
- func RegisterUnion[T any](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 RegisterFieldValidator ¶
func RegisterUnion ¶
func RegisterUnion[T any](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 ¶
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 ¶
func (c *UnionUnmarshaler[T]) UnmarshalJSON(buf []byte) error
Click to show internal directories.
Click to hide internal directories.