Documentation
¶
Overview ¶
Package json implements an ifaces.Adapter using github.com/mailru/easyjson.
Index ¶
- func BorrowAdapterIface() ifaces.Adapter
- func BorrowLexer(data []byte) *jlexer.Lexer
- func BorrowWriter() *jwriter.Writer
- func RedeemAdapter(a *Adapter)
- func RedeemAdapterIface(a ifaces.Adapter)
- func RedeemLexer(l *jlexer.Lexer)
- func RedeemWriter(w *jwriter.Writer)
- func Register(dispatcher ifaces.Registrar, opts ...Option)
- 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) MarshalEasyJSON(w *jwriter.Writer)
- 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) UnmarshalEasyJSON(in *jlexer.Lexer)
- func (s *MapSlice) UnmarshalJSON(data []byte) error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BorrowAdapterIface ¶
func BorrowLexer ¶
BorrowLexer borrows a jlexer.Lexer from the pool, recycling already allocated instances.
func BorrowWriter ¶
BorrowWriter borrows a jwriter.Writer from the pool, recycling already allocated instances.
func RedeemAdapter ¶
func RedeemAdapter(a *Adapter)
RedeemAdapter redeems an Adapter to the pool, so it may be recycled.
func RedeemAdapterIface ¶
func RedeemLexer ¶
RedeemLexer redeems a jlexer.Lexer to the pool, so it may be recycled.
func RedeemWriter ¶
RedeemWriter redeems a jwriter.Writer to the pool, so it may be recycled.
func Register ¶
Register the easyjson implementation of a ifaces.Adapter to the an ifaces.Registrar, e.g. the global registry github.com/go-openapi/swag/jsonutils/adapters.Registry.
Register calls ifaces.Registrar.RegisterFor.
Some optional features proposed by the jwriter.Writer and jlexer.Lexer are available. See Option.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func BorrowAdapter ¶
func BorrowAdapter() *Adapter
BorrowAdapter borrows an Adapter from the pool, recycling already allocated instances.
func NewAdapter ¶
NewAdapter yields a JSON adapter for easyjson.
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.
func (MapItem) MarshalEasyJSON ¶
MarshalEasyJSON renders a MapItem as JSON bytes, using easyJSON
type MapSlice ¶
type MapSlice []MapItem
MapSlice represents a JSON object, with the order of keys maintained.
It implements ifaces.Ordered and ifaces.SetOrdered.
func (MapSlice) MarshalEasyJSON ¶
MarshalEasyJSON renders a MapSlice as JSON bytes, using easyJSON
func (MapSlice) MarshalJSON ¶
MarshalJSON renders a MapSlice as JSON bytes, preserving the order of keys.
func (MapSlice) OrderedMarshalJSON ¶
func (*MapSlice) OrderedUnmarshalJSON ¶
func (*MapSlice) UnmarshalEasyJSON ¶
UnmarshalEasyJSON builds a MapSlice from JSON bytes, using easyJSON
type Option ¶
type Option func(o *options)
Option selects options for the easyjson adapter.