Documentation
¶
Overview ¶
Package adapters exposes a registry of adapters to multiple JSON serialization libraries.
All interfaces are defined in package ifaces.Adapter.
Index ¶
- Variables
- func MarshalAdapterFor(value any) ifaces.MarshalAdapter
- func NewOrderedMap(capacity int) ifaces.OrderedMap
- func OrderedMarshalAdapterFor(value ifaces.Ordered) ifaces.OrderedMarshalAdapter
- func OrderedUnmarshalAdapterFor(value ifaces.SetOrdered) ifaces.OrderedUnmarshalAdapter
- func UnmarshalAdapterFor(value any) ifaces.UnmarshalAdapter
- type Registrar
Constants ¶
This section is empty.
Variables ¶
var ErrRegistry registryError = "JSON adapters registry error"
ErrRegistry indicates an error returned by the Registrar.
var Registry = NewRegistrar()
Registry holds the global registry for registered adapters.
Functions ¶
func MarshalAdapterFor ¶
func MarshalAdapterFor(value any) ifaces.MarshalAdapter
MarshalAdapterFor returns the first adapter that knows how to Marshal this type of value.
func NewOrderedMap ¶
func NewOrderedMap(capacity int) ifaces.OrderedMap
NewOrderedMap provides the "ordered map" implementation provided by the registry.
func OrderedMarshalAdapterFor ¶
func OrderedMarshalAdapterFor(value ifaces.Ordered) ifaces.OrderedMarshalAdapter
OrderedMarshalAdapterFor returns the first adapter that knows how to OrderedMarshal this type of value.
func OrderedUnmarshalAdapterFor ¶
func OrderedUnmarshalAdapterFor(value ifaces.SetOrdered) ifaces.OrderedUnmarshalAdapter
OrderedUnmarshalAdapterFor provides the first adapter that knows how to OrderedUnmarshal this type of value.
func UnmarshalAdapterFor ¶
func UnmarshalAdapterFor(value any) ifaces.UnmarshalAdapter
UnmarshalAdapterFor returns the first adapter that knows how to Unmarshal this type of value.
Types ¶
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
Registrar holds registered ifaces.Adapters for different serialization capabilities.
Internally, it maintains a cache for data types that favor a given adapter.
func NewRegistrar ¶
func NewRegistrar() *Registrar
func (*Registrar) AdapterFor ¶
AdapterFor returns an ifaces.Adapter that supports this capability for this type of value.
The ifaces.Adapter may be redeemed to its pool using its Redeem() method, for adapters that support global pooling. When this is not the case, the redeem function is just a no-operation.
func (*Registrar) ClearCache ¶
func (r *Registrar) ClearCache()
ClearCache resets the internal type cache.
func (*Registrar) RegisterFor ¶
func (r *Registrar) RegisterFor(entry ifaces.RegistryEntry)
RegisterFor registers an adapter for some JSON capabilities.
Directories
¶
Path | Synopsis |
---|---|
easyjson
module
|
|
Package ifaces exposes all interfaces to work with adapters.
|
Package ifaces exposes all interfaces to work with adapters. |
Package stdlib exposes a JSON adapter built on top of the standard library.
|
Package stdlib exposes a JSON adapter built on top of the standard library. |
json
Package json implements an ifaces.Adapter using the standard library.
|
Package json implements an ifaces.Adapter using the standard library. |