Documentation
¶
Index ¶
- Variables
- func Encode(value Value) ([]byte, error)
- func Match(a Value, b Value) bool
- func Valid(src []byte) error
- type Iterator
- type Member
- type ParseError
- type Position
- type String
- type SyntaxError
- type Type
- type Value
- func Decode(input []byte) (Value, error)
- func NewArray(values []Value) Value
- func NewBool(value bool) Value
- func NewNull() Value
- func NewNumber(raw []byte) Value
- func NewNumberFloat64(v float64) Value
- func NewNumberInt64(v int64) Value
- func NewNumberUint64(v uint64) Value
- func NewObject(members []Member) Value
- func NewString(text string) Value
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidType means your Value is of InvalidType. ErrInvalidType = errors.New("Invalid Value") // ErrNotDocument means you have provided a non-array or non-object type where // a valid JSON Document type is expected. ErrNotDocument = errors.New("Not a JSON Document. Expected Array or Object Type") )
Functions ¶
Types ¶
type Iterator ¶
type Iterator interface { // Next returns the next value if any or nil. // More indicates whatever there is any more // _possible_ values, so you must always check // to make sure the item is not nil. // Calling Next after the last item MUST return // `nil, false`. Next() (item Value, more bool) // Len returns -1 for indefinite streams or an advisory // number indicating the the number of values it holds. // The iterator _MAY_ return more or less items than what // is advised but _MUST_ always return a finite // number of items when Len returns 1 or more. // 0 indicates exactly 0 items. Len() int }
Iterator is the common interface for JSON iterators.
type Member ¶
type Member interface { // Tag is the struct member tag. Tag() string Name() *string Value() Value }
Member is a JSON object Member.
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError holds an error and offset, the error maybe a a SyntaxError
func (ParseError) Error ¶
func (pe ParseError) Error() string
type String ¶
type String *string
The String type is simply a string. It merely exists to keep the fmt package from calling it and resulting in panics.
type SyntaxError ¶
SyntaxError is JSON syntax error with a message and int's position.
func (SyntaxError) Error ¶
func (se SyntaxError) Error() string
type Type ¶
type Type uint
A Type describes the type of a value as per JSON spec.
Type of Objects as per the JSON spec.
type Value ¶
type Value interface { Type() Type // Object applies to Object type. Member(string) Value Members() []Member // Array applies to Array type. Values() []Value // Bool applies to Bool type. Bool() bool // Number applies to Number type. Float64() (float64, error) Int64() (int64, error) Uint64() (uint64, error) Raw() []byte // String applies to string type. String() String }
Value is the json value. The Methods should be only called on specified type documented. Null type accepts no methods.
func NewNumber ¶
NewNumber creates a number type from provided raw value. It is the callers responsiblity to make sure it is correctly encoded JSON numbers.
func NewNumberFloat64 ¶
NewNumberFloat64 creates a number from the provided value.
func NewNumberInt64 ¶
NewNumberInt64 creates a number from the provided value.
func NewNumberUint64 ¶
NewNumberUint64 creates a number from the provided value.