Documentation ¶
Index ¶
- Variables
- func AddType(encoder *gojay.Encoder, typed types.Type, value interface{})
- func AddTypeKey(encoder *gojay.Encoder, key string, typed types.Type, value interface{})
- func BoolEmpty(val interface{}) bool
- func BytesBase64Empty(val interface{}) string
- func DecodeType(decoder *gojay.Decoder, prop types.Type) (interface{}, error)
- func Float32Empty(val interface{}) float32
- func Float64Empty(val interface{}) float64
- func Int32Empty(val interface{}) int32
- func Int64Empty(val interface{}) int64
- func StringEmpty(val interface{}) string
- func Uint32Empty(val interface{}) uint32
- func Uint64Empty(val interface{}) uint64
- type Array
- type Constructor
- type Enum
- func (template Enum) Marshal(encoder *gojay.Encoder, store references.Store, tracker references.Tracker)
- func (template Enum) MarshalKey(encoder *gojay.Encoder, key string, store references.Store, ...)
- func (template Enum) Unmarshal(decoder *gojay.Decoder, path string, store references.Store, ...) error
- type ErrUndefinedSpecs
- type Manager
- type Object
- type Scalar
- func (template Scalar) Marshal(encoder *gojay.Encoder, store references.Store, tracker references.Tracker)
- func (template Scalar) MarshalKey(encoder *gojay.Encoder, key string, store references.Store, ...) bool
- func (template Scalar) Unmarshal(decoder *gojay.Decoder, path string, store references.Store, ...) error
Constants ¶
This section is empty.
Variables ¶
var ErrUnknownType = errors.New("unknown type")
ErrUnknownType is thrown when the given type is unknown
Functions ¶
func AddTypeKey ¶
AddTypeKey encodes the given value into the given encoder
func BoolEmpty ¶
func BoolEmpty(val interface{}) bool
BoolEmpty returns the given value as a bool or a empty bool if the value is nil
func BytesBase64Empty ¶
func BytesBase64Empty(val interface{}) string
BytesBase64Empty returns the given bytes buffer as a base64 string or a empty string if the value is nil
func DecodeType ¶
DecodeType decodes the given property from the given decoder
func Float32Empty ¶
func Float32Empty(val interface{}) float32
Float32Empty returns the given value as a float32 or a empty float32 if the value is nil
func Float64Empty ¶
func Float64Empty(val interface{}) float64
Float64Empty returns the given value as a float64 or a empty float64 if the value is nil
func Int32Empty ¶
func Int32Empty(val interface{}) int32
Int32Empty returns the given value as a int32 or a empty int32 if the value is nil
func Int64Empty ¶
func Int64Empty(val interface{}) int64
Int64Empty returns the given value as a int64 or a empty int64 if the value is nil
func StringEmpty ¶
func StringEmpty(val interface{}) string
StringEmpty returns the given value as a string or a empty string if the value is nil
func Uint32Empty ¶
func Uint32Empty(val interface{}) uint32
Uint32Empty returns the given value as a uint32 or a empty uint32 if the value is nil
func Uint64Empty ¶
func Uint64Empty(val interface{}) uint64
Uint64Empty returns the given value as a uint64 or a empty uint64 if the value is nil
Types ¶
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array represents a JSON array.
func NewArray ¶
func NewArray(path string, template specs.Template, store references.Store, tracker references.Tracker) *Array
NewArray creates a new array to be JSON encoded/decoded.
func (*Array) MarshalJSONArray ¶
MarshalJSONArray encodes the array into the given gojay encoder.
type Constructor ¶
type Constructor struct{}
Constructor is capable of constructing new codec managers for the given resource and specs.
func NewConstructor ¶
func NewConstructor() *Constructor
NewConstructor constructs a new JSON constructor.
func (*Constructor) Name ¶
func (constructor *Constructor) Name() string
Name returns the name of the JSON codec constructor.
func (*Constructor) New ¶
func (constructor *Constructor) New(resource string, specs *specs.ParameterMap) (codec.Manager, error)
New constructs a new JSON codec manager
type Enum ¶
Enum represents a enum type template. This type is used to encode or decode values inside gojay. These values are used to construct messages to a service or a user.
func (Enum) Marshal ¶
func (template Enum) Marshal(encoder *gojay.Encoder, store references.Store, tracker references.Tracker)
Marshal marshals the enum template as a JSON value. If no enum has been defined inside the given reference store is the type ignored.
func (Enum) MarshalKey ¶
func (template Enum) MarshalKey(encoder *gojay.Encoder, key string, store references.Store, tracker references.Tracker)
MarshalKey marshals the enum template as an object field using the given key. The key is not set if the enum value is `null`.
type ErrUndefinedSpecs ¶
type ErrUndefinedSpecs struct{}
ErrUndefinedSpecs occurs when spacs are nil
func (ErrUndefinedSpecs) Error ¶
func (e ErrUndefinedSpecs) Error() string
Error returns a description of the given error as a string
func (ErrUndefinedSpecs) Prettify ¶
func (e ErrUndefinedSpecs) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages a specs object and allows to encode/decode messages.
func (*Manager) Marshal ¶
Marshal marshals the given reference store into a JSON message. This method is called during runtime to encode a new message with the values stored inside the given reference store
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object represents a JSON object
func NewObject ¶
func NewObject(path string, template specs.Template, store references.Store, tracker references.Tracker) *Object
NewObject constructs a new object encoder/decoder for the given specs
func (*Object) MarshalJSONObject ¶
MarshalJSONObject encodes the given specs object into the given gojay encoder
type Scalar ¶
Scalar represents a scalar type such as a string, int or float. The scalar type is used to encode or decode values inside gojay. These values are used to construct messages to a service or user.
func (Scalar) Marshal ¶
func (template Scalar) Marshal(encoder *gojay.Encoder, store references.Store, tracker references.Tracker)
Marshal marshals the scalar template as a JSON value.
func (Scalar) MarshalKey ¶
func (template Scalar) MarshalKey(encoder *gojay.Encoder, key string, store references.Store, tracker references.Tracker) bool
MarshalKey marshals the scalar template as an object field using the given key. The key is not set if the value is `null`.