Documentation ¶
Overview ¶
Velocypack implementation for Go.
Index ¶
- Variables
- func IsBuilderUnexpectedType(err error) bool
- func IsInvalidType(err error) bool
- func IsInvalidUnmarshal(err error) bool
- func IsMarshaler(err error) bool
- func IsParse(err error) bool
- func IsUnmarshalType(err error) bool
- func IsUnsupportedType(err error) bool
- func Unmarshal(data Slice, v interface{}) error
- type ArrayIterator
- type Builder
- func (b *Builder) Add(v interface{}) error
- func (b *Builder) AddKeyValue(key string, v Value) error
- func (b *Builder) AddKeyValuesFromIterator(it *ObjectIterator) error
- func (b *Builder) AddValue(v Value) error
- func (b *Builder) AddValuesFromIterator(it *ArrayIterator) error
- func (b *Builder) Bytes() ([]byte, error)
- func (b *Builder) Clear()
- func (b *Builder) Close() error
- func (b *Builder) GetKey(key string) (Slice, error)
- func (b *Builder) HasKey(key string) (bool, error)
- func (b *Builder) IsClosed() bool
- func (b *Builder) IsEmpty() bool
- func (b *Builder) IsOpenArray() bool
- func (b *Builder) IsOpenObject() bool
- func (b *Builder) OpenArray(unindexed ...bool) error
- func (b *Builder) OpenObject(unindexed ...bool) error
- func (b *Builder) RemoveLast() error
- func (b *Builder) Size() (ValueLength, error)
- func (b *Builder) Slice() (Slice, error)
- func (b *Builder) WriteTo(w io.Writer) (int64, error)
- type BuilderOptions
- type BuilderUnexpectedTypeError
- type Decoder
- type Dumper
- type DumperOptions
- type Encoder
- type InvalidTypeError
- type InvalidUnmarshalError
- type Marshaler
- type MarshalerError
- type ObjectIterator
- type ParseError
- type Parser
- type ParserOptions
- type RawSlice
- type Slice
- func EmptyArraySlice() Slice
- func EmptyObjectSlice() Slice
- func FalseSlice() Slice
- func IllegalSlice() Slice
- func Marshal(v interface{}) (result Slice, err error)
- func MaxKeySlice() Slice
- func Merge(slices ...Slice) (Slice, error)
- func MinKeySlice() Slice
- func NoneSlice() Slice
- func NullSlice() Slice
- func ParseJSON(r io.Reader, options ...ParserOptions) (Slice, error)
- func ParseJSONFromString(json string, options ...ParserOptions) (Slice, error)
- func ParseJSONFromUTF8(json []byte, options ...ParserOptions) (Slice, error)
- func SliceFromHex(v string) Slice
- func SliceFromReader(r io.Reader) (Slice, error)
- func StringSlice(s string) Slice
- func TrueSlice() Slice
- func ZeroSlice() Slice
- func (s Slice) AssertType(t ValueType) error
- func (s Slice) AssertTypeAny(t ...ValueType) error
- func (s Slice) At(index ValueLength) (Slice, error)
- func (s Slice) ByteSize() (ValueLength, error)
- func (s Slice) CompareString(value string) (int, error)
- func (s Slice) Get(attributePath ...string) (Slice, error)
- func (s Slice) GetBinary() ([]byte, error)
- func (s Slice) GetBinaryLength() (ValueLength, error)
- func (s Slice) GetBool() (bool, error)
- func (s Slice) GetDouble() (float64, error)
- func (s Slice) GetInt() (int64, error)
- func (s Slice) GetSmallInt() (int64, error)
- func (s Slice) GetString() (string, error)
- func (s Slice) GetStringLength() (ValueLength, error)
- func (s Slice) GetStringUTF8() ([]byte, error)
- func (s Slice) GetUInt() (uint64, error)
- func (s Slice) GetUTCDate() (time.Time, error)
- func (s Slice) HasKey(keyPath ...string) (bool, error)
- func (s Slice) IsArray() bool
- func (s Slice) IsBCD() bool
- func (s Slice) IsBinary() bool
- func (s Slice) IsBool() bool
- func (s Slice) IsCustom() bool
- func (s Slice) IsDouble() bool
- func (s Slice) IsEmptyArray() bool
- func (s Slice) IsEmptyObject() bool
- func (s Slice) IsEqualString(value string) (bool, error)
- func (s Slice) IsExternal() bool
- func (s Slice) IsFalse() bool
- func (s Slice) IsIllegal() bool
- func (s Slice) IsInt() bool
- func (s Slice) IsInteger() bool
- func (s Slice) IsMaxKey() bool
- func (s Slice) IsMinKey() bool
- func (s Slice) IsNone() bool
- func (s Slice) IsNull() bool
- func (s Slice) IsNumber() bool
- func (s Slice) IsObject() bool
- func (s Slice) IsSmallInt() bool
- func (s Slice) IsSorted() bool
- func (s Slice) IsString() bool
- func (s Slice) IsTrue() bool
- func (s Slice) IsType(t ValueType) bool
- func (s Slice) IsUInt() bool
- func (s Slice) IsUTCDate() bool
- func (s Slice) JSONString(options ...DumperOptions) (string, error)
- func (s Slice) KeyAt(index ValueLength, translate ...bool) (Slice, error)
- func (s Slice) Length() (ValueLength, error)
- func (s Slice) Next() (Slice, error)
- func (s Slice) String() string
- func (s Slice) Type() ValueType
- func (s Slice) ValueAt(index ValueLength) (Slice, error)
- type UnmarshalTypeError
- type Unmarshaler
- type UnsupportedTypeBehavior
- type UnsupportedTypeError
- type Value
- func NewArrayValue(unindexed ...bool) Value
- func NewBinaryValue(value []byte) Value
- func NewBoolValue(value bool) Value
- func NewDoubleValue(value float64) Value
- func NewIntValue(value int64) Value
- func NewMaxKeyValue() Value
- func NewMinKeyValue() Value
- func NewNullValue() Value
- func NewObjectValue(unindexed ...bool) Value
- func NewReflectValue(v reflect.Value) Value
- func NewSliceValue(value Slice) Value
- func NewStringValue(value string) Value
- func NewUIntValue(value uint64) Value
- func NewUTCDateValue(value time.Time) Value
- func NewValue(value interface{}) Value
- type ValueLength
- type ValueType
Constants ¶
This section is empty.
Variables ¶
var ( // NumberOutOfRangeError indicates an out of range error. NumberOutOfRangeError = errors.New("number out of range") // IsNumberOutOfRange returns true if the given error is an NumberOutOfRangeError. IsNumberOutOfRange = isCausedByFunc(NumberOutOfRangeError) // IndexOutOfBoundsError indicates an index outside of array/object bounds. IndexOutOfBoundsError = errors.New("index out of range") // IsIndexOutOfBounds returns true if the given error is an IndexOutOfBoundsError. IsIndexOutOfBounds = isCausedByFunc(IndexOutOfBoundsError) // NeedAttributeTranslatorError indicates a lack of object key translator (smallint|uint -> string). NeedAttributeTranslatorError = errors.New("need attribute translator") // IsNeedAttributeTranslator returns true if the given error is an NeedAttributeTranslatorError. IsNeedAttributeTranslator = isCausedByFunc(NeedAttributeTranslatorError) // InternalError indicates an error that the client cannot prevent. InternalError = errors.New("internal") // IsInternal returns true if the given error is an InternalError. IsInternal = isCausedByFunc(InternalError) // BuilderNeedOpenArrayError indicates an (invalid) attempt to open an array/object when that is not allowed. BuilderNeedOpenArrayError = errors.New("builder need open array") // IsBuilderNeedOpenArray returns true if the given error is an BuilderNeedOpenArrayError. IsBuilderNeedOpenArray = isCausedByFunc(BuilderNeedOpenArrayError) // BuilderNeedOpenObjectError indicates an (invalid) attempt to open an array/object when that is not allowed. BuilderNeedOpenObjectError = errors.New("builder need open object") // IsBuilderNeedOpenObject returns true if the given error is an BuilderNeedOpenObjectError. IsBuilderNeedOpenObject = isCausedByFunc(BuilderNeedOpenObjectError) // BuilderNeedOpenCompoundError indicates an (invalid) attempt to close an array/object that is already closed. BuilderNeedOpenCompoundError = errors.New("builder need open array or object") // IsBuilderNeedOpenCompound returns true if the given error is an BuilderNeedOpenCompoundError. IsBuilderNeedOpenCompound = isCausedByFunc(BuilderNeedOpenCompoundError) DuplicateAttributeNameError = errors.New("duplicate key name") // IsDuplicateAttributeName returns true if the given error is an DuplicateAttributeNameError. IsDuplicateAttributeName = isCausedByFunc(DuplicateAttributeNameError) // BuilderNotClosedError is returned when a call is made to Builder.Bytes without being closed. BuilderNotClosedError = errors.New("builder not closed") // IsBuilderNotClosed returns true if the given error is an BuilderNotClosedError. IsBuilderNotClosed = isCausedByFunc(BuilderNotClosedError) // BuilderKeyAlreadyWrittenError is returned when a call is made to Builder.Bytes without being closed. BuilderKeyAlreadyWrittenError = errors.New("builder key already written") // IsBuilderKeyAlreadyWritten returns true if the given error is an BuilderKeyAlreadyWrittenError. IsBuilderKeyAlreadyWritten = isCausedByFunc(BuilderKeyAlreadyWrittenError) // BuilderKeyMustBeStringError is returned when a key is not of type string. BuilderKeyMustBeStringError = errors.New("builder key must be string") // IsBuilderKeyMustBeString returns true if the given error is an BuilderKeyMustBeStringError. IsBuilderKeyMustBeString = isCausedByFunc(BuilderKeyMustBeStringError) // BuilderNeedSubValueError is returned when a RemoveLast is called without any value in an object/array. BuilderNeedSubValueError = errors.New("builder need sub value") // IsBuilderNeedSubValue returns true if the given error is an BuilderNeedSubValueError. IsBuilderNeedSubValue = isCausedByFunc(BuilderNeedSubValueError) // InvalidUtf8SequenceError indicates an invalid UTF8 (string) sequence. InvalidUtf8SequenceError = errors.New("invalid utf8 sequence") // IsInvalidUtf8Sequence returns true if the given error is an InvalidUtf8SequenceError. IsInvalidUtf8Sequence = isCausedByFunc(InvalidUtf8SequenceError) // NoJSONEquivalentError is returned when a Velocypack type cannot be converted to JSON. NoJSONEquivalentError = errors.New("no JSON equivalent") // IsNoJSONEquivalent returns true if the given error is an NoJSONEquivalentError. IsNoJSONEquivalent = isCausedByFunc(NoJSONEquivalentError) )
var ( // WithStack is called on every return of an error to add stacktrace information to the error. // When setting this function, also set the Cause function. // The interface of this function is compatible with functions in github.com/pkg/errors. // WithStack(nil) must return nil. WithStack = func(err error) error { return err } // Cause is used to get the root cause of the given error. // The interface of this function is compatible with functions in github.com/pkg/errors. // Cause(nil) must return nil. Cause = func(err error) error { return err } )
Functions ¶
func IsBuilderUnexpectedType ¶
IsBuilderUnexpectedType returns true if the given error is an BuilderUnexpectedTypeError.
func IsInvalidType ¶
IsInvalidType returns true if the given error is an InvalidTypeError.
func IsInvalidUnmarshal ¶
IsInvalidUnmarshal returns true if the given error is an InvalidUnmarshalError.
func IsMarshaler ¶
IsMarshaler returns true if the given error is an MarshalerError.
func IsUnmarshalType ¶
IsUnmarshalType returns true if the given error is an UnmarshalTypeError.
func IsUnsupportedType ¶
IsUnsupportedType returns true if the given error is an UnsupportedTypeError.
func Unmarshal ¶
Unmarshal reads v from the given Velocypack encoded data slice.
Unmarshal uses the inverse of the encodings that Marshal uses, allocating maps, slices, and pointers as necessary, with the following additional rules:
To unmarshal VelocyPack into a pointer, Unmarshal first handles the case of the VelocyPack being the VelocyPack literal Null. In that case, Unmarshal sets the pointer to nil. Otherwise, Unmarshal unmarshals the VelocyPack into the value pointed at by the pointer. If the pointer is nil, Unmarshal allocates a new value for it to point to.
To unmarshal VelocyPack into a value implementing the Unmarshaler interface, Unmarshal calls that value's UnmarshalVPack method, including when the input is a VelocyPack Null. Otherwise, if the value implements encoding.TextUnmarshaler and the input is a VelocyPack quoted string, Unmarshal calls that value's UnmarshalText method with the unquoted form of the string.
To unmarshal VelocyPack into a struct, Unmarshal matches incoming object keys to the keys used by Marshal (either the struct field name or its tag), preferring an exact match but also accepting a case-insensitive match. Unmarshal will only set exported fields of the struct.
To unmarshal VelocyPack into an interface value, Unmarshal stores one of these in the interface value:
bool, for VelocyPack Bool's float64 for VelocyPack Double's uint64 for VelocyPack UInt's int64 for VelocyPack Int's string, for VelocyPack String's []interface{}, for VelocyPack Array's map[string]interface{}, for VelocyPack Object's nil for VelocyPack Null. []byte for VelocyPack Binary.
To unmarshal a VelocyPack array into a slice, Unmarshal resets the slice length to zero and then appends each element to the slice. As a special case, to unmarshal an empty VelocyPack array into a slice, Unmarshal replaces the slice with a new empty slice.
To unmarshal a VelocyPack array into a Go array, Unmarshal decodes VelocyPack array elements into corresponding Go array elements. If the Go array is smaller than the VelocyPack array, the additional VelocyPack array elements are discarded. If the VelocyPack array is smaller than the Go array, the additional Go array elements are set to zero values.
To unmarshal a VelocyPack object into a map, Unmarshal first establishes a map to use. If the map is nil, Unmarshal allocates a new map. Otherwise Unmarshal reuses the existing map, keeping existing entries. Unmarshal then stores key-value pairs from the VelocyPack object into the map. The map's key type must either be a string, an integer, or implement encoding.TextUnmarshaler.
If a VelocyPack value is not appropriate for a given target type, or if a VelocyPack number overflows the target type, Unmarshal skips that field and completes the unmarshaling as best it can. If no more serious errors are encountered, Unmarshal returns an UnmarshalTypeError describing the earliest such error.
The VelocyPack Null value unmarshals into an interface, map, pointer, or slice by setting that Go value to nil. Because null is often used in VelocyPack to mean “not present,” unmarshaling a VelocyPack Null into any other Go type has no effect on the value and produces no error.
Types ¶
type ArrayIterator ¶
type ArrayIterator struct {
// contains filtered or unexported fields
}
func NewArrayIterator ¶
func NewArrayIterator(s Slice) (*ArrayIterator, error)
NewArrayIterator initializes an iterator at position 0 of the given object slice.
func (*ArrayIterator) IsFirst ¶
func (i *ArrayIterator) IsFirst() bool
IsFirst returns true if the current position is 0.
func (*ArrayIterator) IsValid ¶
func (i *ArrayIterator) IsValid() bool
IsValid returns true if the given position of the iterator is valid.
func (*ArrayIterator) Value ¶
func (i *ArrayIterator) Value() (Slice, error)
Value returns the value of the current position of the iterator
type Builder ¶
type Builder struct { BuilderOptions // contains filtered or unexported fields }
Builder is used to build VPack structures.
func NewBuilder ¶
func (*Builder) AddKeyValue ¶
AddKeyValue adds a key+value to an open object.
func (*Builder) AddKeyValuesFromIterator ¶
func (b *Builder) AddKeyValuesFromIterator(it *ObjectIterator) error
AddKeyValuesFromIterator adds values to an object from the given iterator. The object must be opened before a call to this function and the object is left open Intentionally.
func (*Builder) AddValuesFromIterator ¶
func (b *Builder) AddValuesFromIterator(it *ArrayIterator) error
AddValuesFromIterator adds values to an array from the given iterator. The array must be opened before a call to this function and the array is left open Intentionally.
func (*Builder) Bytes ¶
Bytes return the generated bytes. The returned slice is shared with the builder itself, so you must not modify it. When the builder is not closed, an error is returned.
func (*Builder) GetKey ¶
GetKey returns the value for a specific key of an Object value. Returns Slice of type None when key is not found.
func (*Builder) IsOpenArray ¶
IsOpenArray returns true when the builder has an open array at the top of the stack.
func (*Builder) IsOpenObject ¶
IsOpenObject returns true when the builder has an open object at the top of the stack.
func (*Builder) OpenObject ¶
OpenObject starts a new object. This must be closed using Close.
func (*Builder) RemoveLast ¶
RemoveLast removes last subvalue written to an (unclosed) object or array.
func (*Builder) Size ¶
func (b *Builder) Size() (ValueLength, error)
Size returns the actual size of the generated slice. Returns an error when builder is not closed.
type BuilderOptions ¶
type BuilderOptions struct { BuildUnindexedArrays bool BuildUnindexedObjects bool CheckAttributeUniqueness bool }
BuilderOptions contains options that influence how Builder builds slices.
type BuilderUnexpectedTypeError ¶
type BuilderUnexpectedTypeError struct {
Message string
}
BuilderUnexpectedTypeError is returned when a Builder function received an invalid type.
func (BuilderUnexpectedTypeError) Error ¶
func (e BuilderUnexpectedTypeError) Error() string
Error implements the error interface for BuilderUnexpectedTypeError.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
A Decoder decodes velocypack values into Go structures.
func NewDecoder ¶
NewDecoder creates a new Decoder that reads data from the given reader.
type Dumper ¶
type Dumper struct {
// contains filtered or unexported fields
}
type DumperOptions ¶
type DumperOptions struct { // EscapeUnicode turns on escapping multi-byte Unicode characters when dumping them to JSON (creates \uxxxx sequences). EscapeUnicode bool // EscapeForwardSlashes turns on escapping forward slashes when serializing VPack values into JSON. EscapeForwardSlashes bool UnsupportedTypeBehavior UnsupportedTypeBehavior }
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
An Encoder encodes Go structures into velocypack values written to an output stream.
func NewEncoder ¶
NewEncoder creates a new Encoder that writes output to the given writer.
type InvalidTypeError ¶
type InvalidTypeError struct {
Message string
}
InvalidTypeError is returned when a Slice getter is called on a slice of a different type.
func (InvalidTypeError) Error ¶
func (e InvalidTypeError) Error() string
Error implements the error interface for InvalidTypeError.
type InvalidUnmarshalError ¶
An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidUnmarshalError) Error ¶
func (e *InvalidUnmarshalError) Error() string
type MarshalerError ¶
MarshalerError is returned when a custom VPack Marshaler returns an error.
func (MarshalerError) Error ¶
func (e MarshalerError) Error() string
Error implements the error interface for MarshalerError.
type ObjectIterator ¶
type ObjectIterator struct {
// contains filtered or unexported fields
}
func NewObjectIterator ¶
func NewObjectIterator(s Slice, allowRandomIteration ...bool) (*ObjectIterator, error)
NewObjectIterator initializes an iterator at position 0 of the given object slice.
func (*ObjectIterator) IsFirst ¶
func (i *ObjectIterator) IsFirst() bool
IsFirst returns true if the current position is 0.
func (*ObjectIterator) IsValid ¶
func (i *ObjectIterator) IsValid() bool
IsValid returns true if the given position of the iterator is valid.
func (*ObjectIterator) Key ¶
func (i *ObjectIterator) Key(translate bool) (Slice, error)
Key returns the key of the current position of the iterator
func (*ObjectIterator) Next ¶
func (i *ObjectIterator) Next() error
Next moves to the next position.
func (*ObjectIterator) Value ¶
func (i *ObjectIterator) Value() (Slice, error)
Value returns the value of the current position of the iterator
type ParseError ¶
type ParseError struct { Offset int64 // contains filtered or unexported fields }
An ParseError is returned when JSON cannot be parsed correctly.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is used to build VPack structures from JSON.
type ParserOptions ¶
type ParserOptions struct { // If set, all Array's will be unindexed. BuildUnindexedArrays bool // If set, all Objects's will be unindexed. BuildUnindexedObjects bool }
ParserOptions controls how the Parser builds Velocypack.
type RawSlice ¶
type RawSlice []byte
RawSlice is a raw encoded Velocypack value. It implements Marshaler and Unmarshaler and can be used to delay Velocypack decoding or precompute a Velocypack encoding.
func (RawSlice) MarshalVPack ¶
MarshalVPack returns m as the Velocypack encoding of m.
func (*RawSlice) UnmarshalVPack ¶
UnmarshalVPack sets *m to a copy of data.
type Slice ¶
type Slice []byte
Slice provides read only access to a VPack value
func EmptyArraySlice ¶
func EmptyArraySlice() Slice
EmptyArraySlice creates a slice of type Array, empty
func EmptyObjectSlice ¶
func EmptyObjectSlice() Slice
EmptyObjectSlice creates a slice of type Object, empty
func FalseSlice ¶
func FalseSlice() Slice
FalseSlice creates a slice of type Boolean with false value
func Marshal ¶
Marshal writes the Velocypack encoding of v to a buffer and returns that buffer.
Marshal traverses the value v recursively. If an encountered value implements the Marshaler interface and is not a nil pointer, Marshal calls its MarshalVPack method to produce Velocypack. If an encountered value implements the json.Marshaler interface and is not a nil pointer, Marshal calls its MarshalJSON method to produce JSON and converts the resulting JSON to VelocyPack. If no MarshalVPack or MarshalJSON method is present but the value implements encoding.TextMarshaler instead, Marshal calls its MarshalText method and encodes the result as a Velocypack string. The nil pointer exception is not strictly necessary but mimics a similar, necessary exception in the behavior of UnmarshalVPack.
Otherwise, Marshal uses the following type-dependent default encodings:
Boolean values encode as Velocypack booleans.
Floating point, integer, and Number values encode as Velocypack Int's, UInt's and Double's.
String values encode as Velocypack strings.
Array and slice values encode as Velocypack arrays, except that []byte encodes as Velocypack Binary data, and a nil slice encodes as the Null Velocypack value.
Struct values encode as Velocypack objects. The encoding follows the same rules as specified for json.Marshal. This means that all `json` tags are fully supported.
Map values encode as Velocypack objects. The encoding follows the same rules as specified for json.Marshal.
Pointer values encode as the value pointed to. A nil pointer encodes as the Null Velocypack value.
Interface values encode as the value contained in the interface. A nil interface value encodes as the Null Velocypack value.
Channel, complex, and function values cannot be encoded in Velocypack. Attempting to encode such a value causes Marshal to return an UnsupportedTypeError.
Velocypack cannot represent cyclic data structures and Marshal does not handle them. Passing cyclic structures to Marshal will result in an infinite recursion.
func Merge ¶
Merge creates a slice that contains all fields from all given slices. When a field exists (with same name) in an earlier slice, it is ignored. All slices must be objects.
func ParseJSON ¶
func ParseJSON(r io.Reader, options ...ParserOptions) (Slice, error)
ParseJSON parses JSON from the given reader and returns the VPack equivalent.
func ParseJSONFromString ¶
func ParseJSONFromString(json string, options ...ParserOptions) (Slice, error)
ParseJSONFromString parses the given JSON string and returns the VPack equivalent.
func ParseJSONFromUTF8 ¶
func ParseJSONFromUTF8(json []byte, options ...ParserOptions) (Slice, error)
ParseJSONFromUTF8 parses the given JSON string and returns the VPack equivalent.
func SliceFromHex ¶
SliceFromHex creates a Slice by decoding the given hex string into a Slice. If decoding fails, nil is returned.
func SliceFromReader ¶
SliceFromReader reads a slice from the given reader.
func StringSlice ¶
StringSlice creates a slice of type String with given string value
func (Slice) AssertType ¶
AssertType returns an error when the vpack type of the slice different from the given type. Returns nil otherwise.
func (Slice) AssertTypeAny ¶
AssertTypeAny returns an error when the vpack type of the slice different from all of the given types. Returns nil otherwise.
func (Slice) At ¶
func (s Slice) At(index ValueLength) (Slice, error)
At extracts the array value at the specified index.
func (Slice) ByteSize ¶
func (s Slice) ByteSize() (ValueLength, error)
ByteSize returns the total byte size for the slice, including the head byte
func (Slice) CompareString ¶
CompareString compares the string value in the slice with the given string. s == value -> 0 s < value -> -1 s > value -> 1
func (Slice) Get ¶
Get looks for the specified attribute path inside an Object returns a Slice(ValueType::None) if not found
func (Slice) GetBinaryLength ¶
func (s Slice) GetBinaryLength() (ValueLength, error)
GetBinaryLength return the length for a Binary object
func (Slice) GetBool ¶
GetBool returns a boolean value from the slice. Returns an error if slice is not of type Bool.
func (Slice) GetDouble ¶
GetDouble returns a Double value from the slice. Returns an error if slice is not of type Double.
func (Slice) GetInt ¶
GetInt returns a Int value from the slice. Returns an error if slice is not of type Int.
func (Slice) GetSmallInt ¶
GetSmallInt returns a SmallInt value from the slice. Returns an error if slice is not of type SmallInt.
func (Slice) GetString ¶
GetString return the value for a String object This function is a bit slower than GetStringUTF8, since the conversion from []byte to string needs a memory allocation.
func (Slice) GetStringLength ¶
func (s Slice) GetStringLength() (ValueLength, error)
GetStringLength return the length for a String object
func (Slice) GetStringUTF8 ¶
GetStringUTF8 return the value for a String object as a []byte with UTF-8 values. This function is a bit faster than GetString, since the conversion from []byte to string needs a memory allocation.
func (Slice) GetUInt ¶
GetUInt returns a UInt value from the slice. Returns an error if slice is not of type UInt.
func (Slice) GetUTCDate ¶
GetUTCDate return the value for an UTCDate object
func (Slice) IsEmptyArray ¶
IsEmptyArray tests whether the Slice is an empty array
func (Slice) IsEmptyObject ¶
IsEmptyObject tests whether the Slice is an empty object
func (Slice) IsEqualString ¶
IsEqualString compares the string value in the slice with the given string for equivalence.
func (Slice) IsExternal ¶
IsExternal returns true if slice is an External object
func (Slice) IsSmallInt ¶
IsSmallInt returns true if slice is a SmallInt object
func (Slice) IsSorted ¶
IsSorted returns true if slice is an object with table offsets, sorted by attribute name
func (Slice) IsType ¶
IsType returns true when the vpack type of the slice is equal to the given type. Returns false otherwise.
func (Slice) JSONString ¶
func (s Slice) JSONString(options ...DumperOptions) (string, error)
JSONString converts the contents of the slice to JSON.
func (Slice) KeyAt ¶
func (s Slice) KeyAt(index ValueLength, translate ...bool) (Slice, error)
KeyAt extracts a key from an Object at the specified index.
func (Slice) Length ¶
func (s Slice) Length() (ValueLength, error)
Length return the number of members for an Array or Object object
func (Slice) Next ¶
Next returns the Slice that directly follows the given slice. Same as s[s.ByteSize:]
type UnmarshalTypeError ¶
type UnmarshalTypeError struct { Value string // description of JSON value - "bool", "array", "number -5" Type reflect.Type // type of Go value it could not be assigned to Struct string // name of the struct type containing the field Field string // name of the field holding the Go value }
An UnmarshalTypeError describes a JSON value that was not appropriate for a value of a specific Go type.
func (*UnmarshalTypeError) Error ¶
func (e *UnmarshalTypeError) Error() string
type Unmarshaler ¶
Unmarshaler is implemented by types that can convert themselves from Velocypack.
type UnsupportedTypeBehavior ¶
type UnsupportedTypeBehavior int
const ( NullifyUnsupportedType UnsupportedTypeBehavior = iota ConvertUnsupportedType FailOnUnsupportedType )
type UnsupportedTypeError ¶
UnsupportedTypeError is returned when a type is marshaled that cannot be marshaled.
func (UnsupportedTypeError) Error ¶
func (e UnsupportedTypeError) Error() string
Error implements the error interface for UnsupportedTypeError.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is a helper structure used to build VPack structures. It holds a single data value with a specific type.
func NewArrayValue ¶
NewArrayValue creates a new Value that opens a new array.
func NewBinaryValue ¶
NewBinaryValue creates a new Value of type Binary with given value.
func NewBoolValue ¶
NewBoolValue creates a new Value of type Bool with given value.
func NewDoubleValue ¶
NewDoubleValue creates a new Value of type Double with given value.
func NewIntValue ¶
NewIntValue creates a new Value of type Int with given value.
func NewMaxKeyValue ¶
func NewMaxKeyValue() Value
NewMaxKeyValue creates a new Value of type MaxKey.
func NewMinKeyValue ¶
func NewMinKeyValue() Value
NewMinKeyValue creates a new Value of type MinKey.
func NewObjectValue ¶
NewObjectValue creates a new Value that opens a new object.
func NewReflectValue ¶
NewReflectValue creates a new Value with type derived from Go type of given reflect value. If the given value is not a supported type, a Value of type Illegal is returned.
func NewSliceValue ¶
NewSliceValue creates a new Value of from the given slice.
func NewStringValue ¶
NewStringValue creates a new Value of type String with given value.
func NewUIntValue ¶
NewUIntValue creates a new Value of type UInt with given value.
func NewUTCDateValue ¶
NewUTCDateValue creates a new Value of type UTCDate with given value.
func NewValue ¶
func NewValue(value interface{}) Value
NewValue creates a new Value with type derived from Go type of given value. If the given value is not a supported type, a Value of type Illegal is returned.
type ValueLength ¶
type ValueLength uint64
func (ValueLength) String ¶
func (s ValueLength) String() string
Source Files ¶
- array_iterator.go
- attribute_translator.go
- builder.go
- builder_buffer.go
- builder_index_vector.go
- builder_sort_entry.go
- builder_stack.go
- decoder.go
- doc.go
- dumper.go
- encoder.go
- encoder_field.go
- encoder_fold.go
- encoder_tags.go
- error.go
- object_iterator.go
- parser.go
- raw_slice.go
- slice.go
- slice_factory.go
- slice_merge.go
- slice_reader.go
- slice_type.go
- util.go
- value.go
- value_length.go
- value_type.go