Documentation
¶
Index ¶
- func MarshalJSON(c ctx.C, from any) ([]byte, error)
- func MarshalMsgPack(c ctx.C, from any) ([]byte, error)
- func MustMarshalJSON(c ctx.C, from any) []byte
- func MustMarshalMsgPack(c ctx.C, from any) []byte
- func MustUnmarshal(c ctx.C, n Node, into any)
- func NewPipe(buf int) (Pipe, Pipe)
- func Register[T any](h *Handler, f func(ctx.C, Node) (T, error))
- func Unmarshal(c ctx.C, n Node, into any) error
- func UnmarshalInto(c ctx.C, n Node, into any) error
- func UnmarshalJSON(c ctx.C, j []byte, into any) error
- func UnmarshalMsgPack(c ctx.C, data []byte, into any) error
- type Bool
- type Bytes
- type Closer
- type Codec
- type Digits
- func (this Digits) Duration(unit time.Duration) Duration
- func (this Digits) Float64() (float64, error)
- func (this Digits) GoString() string
- func (this Digits) Int64() (int64, error)
- func (this Digits) IsFloat() bool
- func (this Digits) MarshalJSON() ([]byte, error)
- func (this Digits) MustFloat() Float
- func (this Digits) MustInteger() Integer
- func (this Digits) MustUint() uint64
- func (this Digits) String() string
- func (this Digits) Uint64() (uint64, error)
- type Duration
- type Float
- func (this Float) Duration(unit time.Duration) Duration
- func (this Float) Float64() (float64, error)
- func (this Float) GoString() string
- func (this Float) Int64() (int64, error)
- func (this Float) MarshalJSON() ([]byte, error)
- func (this Float) String() string
- func (this Float) Uint64() (uint64, error)
- type Handler
- func (this Handler) Append(p any) Handler
- func (this Handler) Marshal(c ctx.C, in any) (Node, error)
- func (this Handler) MarshalStruct(c ctx.C, in any, pairs ...Pair) (Pairs, error)
- func (this Handler) Unmarshal(c ctx.C, n Node, into any) error
- func (h Handler) UnmarshalInto(c ctx.C, n Node, into any) error
- type Integer
- func (this Integer) Duration(unit time.Duration) Duration
- func (this Integer) Float64() (float64, error)
- func (this Integer) GoString() string
- func (this Integer) Int64() (int64, error)
- func (this Integer) MarshalJSON() ([]byte, error)
- func (this Integer) String() string
- func (this Integer) Uint64() (uint64, error)
- type Iterable
- type JSON
- type List
- type Map
- type Marshaler
- type MsgPack
- type Nil
- type Node
- type Numeric
- type Pair
- type Pairs
- type Pipe
- type ReadWriteCloser
- type ReadWriter
- type Reader
- type ReaderCloser
- type String
- type Tag
- type Time
- type Unmarshaler
- type WriteCloser
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register registers a factory function for type T. When h is nil, registers globally (must be called during init()). When h is non-nil, registers on that specific Handler instance (can be called anytime). Note: The factory is registered as *T, not T, so unmarshal lookup checks both T and *T.
func UnmarshalInto ¶
skip the factory and unmarshal and directly unmarshal into the object, useful inside a custo Unmarshaler
Types ¶
type Duration ¶
Use this object if you want to get `1s` from time.Second the built in json library encode time.Second as 1000000000 empty string is used for zero duration
func (Duration) MarshalJSON ¶
func (*Duration) UnmarshalJSON ¶
type Handler ¶
type Handler struct {
Factory map[reflect.Type]func(c ctx.C, n Node) (any, error)
// called if a field is present in the NodeTree but there is no mapping on the object it's unmarshaled into
UnhandledFields func(c ctx.C, path []any, n Node) error
Debugf func(c ctx.C, f string, args ...any)
// contains filtered or unexported fields
}
generic object that do the Unmarshal()/Conflate()
func (Handler) MarshalStruct ¶
type List ¶
type List []Node
type Node ¶
type Pairs ¶
type Pairs []Pair
ordered pairs, used mostly internally when Marshalling structs, to preserve the order of the fields can be used anywhere else where the order matters
func MarshalStruct ¶
transform a struct into a enc.Node, using the struct tags to determine the field names and options, allow custom pairs this can be useful for adding a "type" field to a struct:
func (f Filter) MarshalNode(c ctx.C) (enc.Node, error) {
return enc.MarshalStruct(c, f, enc.Pair{Name: "type", Value: enc.String("filter")})
}
func (Pairs) MarshalJSON ¶
type Pipe ¶
NOTE(oha): not sure if we really need this, left around for now might either add test or remove later
type ReadWriteCloser ¶
type ReadWriter ¶
type ReaderCloser ¶
type Unmarshaler ¶
objects which implements this can override how their data is unmarshaled (Expand)