Documentation
¶
Overview ¶
Package types defines common types to work with json.
The JSON grammar defines four primitive types: strings, numbers, booleans and null.
The null type may only have the single value "null".
A value may be either defined or undefined. Notice that "null" doesn't mean undefined.
An undefined value will marshal as empty in JSON, whereas a "null" will unmarshal as the "null" token.
Strings, numbers and booleans may not be null. This package exposes a Nullable wrapper to support types that may be string or null, numbers or null and boolean or null.
Index ¶
- Variables
- func CompareNumbers(a, b Number) int
- func Equal(a, b Number) bool
- func Greater(a, b Number) bool
- func GreaterOrEqual(a, b Number) bool
- func Less(a, b Number) bool
- func LessOrEqual(a, b Number) bool
- type Boolean
- type BytesLoaderFunc
- type Definable
- type DocumentShareable
- type ErrStateSetter
- type NullType
- type Nullable
- type Number
- type Resettable
- type String
- type WithErrState
Constants ¶
This section is empty.
Variables ¶
var ( // Zero numerical value Zero = Number{Value: []byte{'0'}} // True JSON value True = Boolean{Value: true, /* contains filtered or unexported fields */} // False JSON value False = Boolean{Value: false, /* contains filtered or unexported fields */} // EmptyString is the empty string "" EmptyString = String{Value: []byte{}} // Null JSON value Null = NullType{/* contains filtered or unexported fields */} )
Functions ¶
func CompareNumbers ¶
func GreaterOrEqual ¶
func LessOrEqual ¶
Types ¶
type Boolean ¶
type Boolean struct { Value bool // contains filtered or unexported fields }
Boolean represents a JSON boolean value.
type BytesLoaderFunc ¶
TODO: should be from reader
type DocumentShareable ¶
type DocumentShareable interface { BytesLoaderFunc }Loader()
DocumentShareable allows a [stores.Store] object to share services across the [json.Document]s it holds. TODO: don't know yet
type ErrStateSetter ¶
type ErrStateSetter interface {
SetErr(error)
}
ErrSetter is the common interface for all types that accept that callers may override their internal error state.
type Nullable ¶
type Nullable[T Definable] struct { Inner T // contains filtered or unexported fields }
Nullable is a wrapper type for any type that supports IsDefined() bool.
type Number ¶
type Number struct {
Value []byte
}
Number represents a JSON number.
type Resettable ¶
type Resettable = pools.Resettable
Resettable is implemented by types that can reset their state.
This is useful when working with pools.
type WithErrState ¶
WithErrState is the common interface for all types that manage an internal error state.
This is useful to descend a hierarchical structure without stacking return errors.