Documentation
¶
Overview ¶
Package json implements the RedisJSON (JSON.*) command family on top of the effects engine's virtual-partition keys. This file defines the internal, dependency-free JSON value model. Object member order is preserved (a RedisJSON requirement) by storing members as an ordered slice, not a Go map.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Serialize ¶
Serialize renders v to canonical compact JSON bytes. This is the form stored in scalar leaf partitions and returned for legacy single-value replies.
func SerializePretty ¶
SerializePretty renders v with JSON.GET formatting options. With an empty PrintOpts it is byte-identical to Serialize.
Types ¶
type Kind ¶
type Kind uint8
Kind enumerates the JSON value kinds. RedisJSON distinguishes "integer" from "number", so integral and fractional numbers are separate kinds.
type Path ¶
type Path struct {
JSONPath bool
// contains filtered or unexported fields
}
Path is a parsed JSON path. JSONPath ($-prefixed) resolves to all matches and is reported as an array; legacy (leading '.' or bare) resolves to the first match and is reported bare.
func ParsePath ¶
ParsePath parses a RedisJSON path in either dialect. Both dialects share the full grammar — object/array steps, wildcard (* / [*]), array slice ([start:end:step]), union ([a,b] / ['x','y']), recursive descent (..), and filter ([?(@.x>1)]). The dialects differ only in how the resolved matches are reported (JSONPath → array of all; legacy → the first match bare).
type PrintOpts ¶
type PrintOpts struct {
Indent string // inserted once per nesting level
Newline string // inserted after the opening brace/bracket and each element
Space string // inserted after ':' in objects
}
PrintOpts controls JSON.GET pretty-printing. All-empty == compact.
type Value ¶
type Value struct {
Kind Kind
Bool bool
Int int64
Float float64
Str string
Arr []*Value
Obj []Member
}
Value is the internal JSON model. Exactly one payload field is meaningful per Kind. Objects keep insertion order via the Obj slice.
func Parse ¶
Parse decodes JSON bytes into the ordered model. It streams tokens via encoding/json so object key order is preserved (json.Unmarshal into a map would lose it), and uses UseNumber so integers vs floats are classified without float64 precision loss on large integers.
func (*Value) IsContainer ¶
IsContainer reports whether v is an object or array (vs a scalar leaf).