Documentation
¶
Overview ¶
Package json implements an ifaces.Adapter using the standard library.
Index ¶
- Variables
- func BorrowAdapterIface() ifaces.Adapter
- func RedeemAdapter(a *Adapter)
- func RedeemAdapterIface(a ifaces.Adapter)
- func Register(dispatcher ifaces.Registrar)
- type Adapter
- func (a *Adapter) Marshal(value any) ([]byte, error)
- func (a *Adapter) NewOrderedMap(capacity int) ifaces.OrderedMap
- func (a *Adapter) OrderedMarshal(value ifaces.Ordered) ([]byte, error)
- func (a *Adapter) OrderedUnmarshal(data []byte, value ifaces.SetOrdered) error
- func (a *Adapter) Redeem()
- func (a *Adapter) Reset()
- func (a *Adapter) Unmarshal(data []byte, value any) error
- type MapItem
- type MapSlice
- func (s MapSlice) MarshalJSON() ([]byte, error)
- func (s MapSlice) OrderedItems() iter.Seq2[string, any]
- func (s MapSlice) OrderedMarshalJSON() ([]byte, error)
- func (s *MapSlice) OrderedUnmarshalJSON(data []byte) error
- func (s *MapSlice) SetOrderedItems(items iter.Seq2[string, any])
- func (s *MapSlice) UnmarshalJSON(data []byte) error
Constants ¶
This section is empty.
Variables ¶
var ErrStdlib jsonError = "error from the JSON adapter stdlib"
ErrStdlib indicates that an error comes from the stdlib JSON adapter
Functions ¶
func BorrowAdapterIface ¶
BorrowAdapterIface borrows a stdlib Adapter and converts it directly to ifaces.Adapter. This is useful to avoid further allocations when translating the concrete type into an interface.
func RedeemAdapter ¶
func RedeemAdapter(a *Adapter)
RedeemAdapter redeems an Adapter to the pool, so it may be recycled.
func RedeemAdapterIface ¶
Types ¶
type Adapter ¶
type Adapter struct { }
func BorrowAdapter ¶
func BorrowAdapter() *Adapter
BorrowAdapter borrows an Adapter from the pool, recycling already allocated instances.
func NewAdapter ¶
func NewAdapter() *Adapter
NewAdapter yields an ifaces.Adapter using the standard library.
func (*Adapter) NewOrderedMap ¶
func (a *Adapter) NewOrderedMap(capacity int) ifaces.OrderedMap
func (*Adapter) OrderedMarshal ¶
func (*Adapter) OrderedUnmarshal ¶
func (a *Adapter) OrderedUnmarshal(data []byte, value ifaces.SetOrdered) error
type MapItem ¶
MapItem represents the value of a key in a JSON object held by MapSlice.
Notice that MapItem should not be marshaled to or unmarshaled from JSON directly, use this type as part of a MapSlice when dealing with JSON bytes.
type MapSlice ¶
type MapSlice []MapItem
MapSlice represents a JSON object, with the order of keys maintained.
func (MapSlice) MarshalJSON ¶
MarshalJSON renders a MapSlice as JSON bytes, preserving the order of keys.