package
0.0.0-20240914090759-22fe844ec72e
Repository: https://github.com/couchbase/query.git
Documentation: pkg.go.dev
# README
a delayed parsing value system
The goal is offer a consistent type structure to allow you to process JSON end-to-end with minimal parsing.
Features
- Create Value objects with unparsed JSON bytes or with JSON compatible go datatypes
- Access nested data using Field() and Index() methods
- these also return Value objects (or Undefined) allowing you to delay parsing of nested objects as well
- Values of type OBJECT and ARRAY are mutable
- SetField() and SetIndex() allow you to overlay new Values into these objects
- Returning to []byte can be done at any time by calling Bytes()
- the underlying raw bytes are reused if possible to avoid JSON encoding
- Exit the type system at any time by calling Actual()
- this will trigger parsing of any required values that have not yet been parsed
- Arbitrary data may be attached to a Value using the Set/Get/Remove Attachment() methods
- Check the type of Value using the Type() method
Documentation
See GoDoc
Performance
Two simple benchmarks which process a 1MB JSON file. The first uses NewValue() with Field(), Index() and Actual() calls and the second using json.Unmarshal() and map/slice calls. Both versions access the same property.
$ go test -bench .
PASS
BenchmarkLargeValue 20 76905386 ns/op 25.23 MB/s
BenchmarkLargeMap 20 116378934 ns/op 16.67 MB/s
Usage
// read some JSON
bytes := []byte(`{"type":"test"}`)
// create a Value object
doc := value.NewValueFromBytes(bytes)
// attempt to access a nested Value
docType, err := doc.Field("type")
if err != nil {
panic("no property type exists")
}
// convert docType to a native go value
docTypeValue := docType.Actual()
// display the value
fmt.Printf("document type is %v\n", docTypeValue)
Output
$ ./example
document type is test
# Packages
No description provided by the author
# Functions
No description provided by the author
Used by some Value.Size() functions to obtain the size of elements.
This is analogous to util.ApplyDurationStyle but operates on the fields found in Value objects The assumption remains that the value was produced with the currently-in-effect default duration style so if the request format matches that, no action is necessary.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
when we know val is an array ([]interface{}).
when we know val is a single value.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Returns variable MISING_VALUE.
No description provided by the author
shorthand for a scope value that is going to contain nested annotated values.
Returns a NULL_VALUE.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
numeric is a flag to restrict the Set to only contain numeric values(float64 and int64).
No description provided by the author
No description provided by the author
No description provided by the author
Bring a data object into the Value type system from a Go Type.
No description provided by the author
No description provided by the author
No description provided by the author
Function ToBool converts a Tristate value to a boolean.
No description provided by the author
Function ToTristate converts a boolean into a Tristate type.
No description provided by the author
# Constants
JSON array.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
non-JSON.
JSON boolean.
No description provided by the author
Non-specific JSON; used in result sets.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Missing field.
No description provided by the author
Explicit null.
JSON number.
JSON object.
we try to find a balance between the need to have a find state and the cost of using it: for documents shorter than this, not worth it! (unless we'll be extracting only a few fields).
JSON string.
No description provided by the author
# Variables
No description provided by the author
EMPTY_ARRAY_VALUE is initialized as a slice of interface.
No description provided by the author
Define a value representing an empty string and
assign it to EMPTY_STRING_VALUE.
No description provided by the author
Initialized to an empty string cast to missingValue.
No description provided by the author
No description provided by the author
Initialized as a pointer to an empty nullValue.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
Value-JoinKeys pair.
No description provided by the author
Key-value pair.
No description provided by the author
Bag implements a multiset of Values.
No description provided by the author
No description provided by the author
List implements a slice of Values as []value.Value.
MultiSet implements a hash map of Values with number of occurrences.
Key-value-options pair.
No description provided by the author
ScopeValue provides alias scoping for subqueries, ranging, LETs,
projections, etc.
Set implements a hash set of Values.
No description provided by the author
Sorter sorts an ARRAY Value in place.
No description provided by the author
No description provided by the author
No description provided by the author
Key-value pair.
# Interfaces
AnnotatedValue is a Value that can hold attachments and can hold data
from covering indexes.
No description provided by the author
An interface for storing and manipulating a JSON value.Each 'value'
implements the methods that correspond to it.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
For token search.
No description provided by the author
No description provided by the author
The data types supported by Value, present and supported in N1QL.
When you try to set a nested property or index that does not exist,
the return error will be Unsettable.
Value collections
*/.
No description provided by the author