type
Value
An immutable scalar, object, list, or populated document value.
Properties
| Property | Type | Description |
|---|---|---|
Kind() | ValueKind | Null, string, object, populated document, number, boolean, or list. |
StringValue() | (string, | String payload and matching-kind flag. |
NumberValue() | (float64, | Numeric payload and matching-kind flag. |
BooleanValue() | (bool, | Boolean payload and matching-kind flag. |
Get(name) | Value | Direct immutable object child; returns Null for a missing key or non-object. |
Lookup(name) | (Value, | Direct immutable object child and a membership flag. |
Entries() | iter.Seq2[string, | Object members without copying; iteration order is unspecified. |
Elements() | iter.Seq[Value] | List items without copying, in stored order. |
Len() | int | Object member or list item count; zero for other kinds. |
ListItem(index) | (Value, | One immutable list item and an in-range flag. |
WithListItem(index, replacement) | (Value, | A list with one replacement, sharing unchanged items. |
CopyObject() | (Values, | Detached mutable object map and matching-kind flag. |
CopyList() | ([]Value, | Detached mutable list slice and matching-kind flag. |
CopyDocument() | (Document, | Detached populated document and matching-kind flag. |
How it works
Ordinary child lookups and iteration share immutable values. Constructors detach mutable inputs; CopyObject, CopyList and CopyDocument explicitly request mutable copies. Existing values keep their snapshots after a replacement.
Full signature
type Value struct {
// contains filtered or unexported fields
}Methods
Value.StringValue()Read the string payload when this value has string kind.
Value.BooleanValue()Public method Value.BooleanValue from github.com/riducms/ridu/store.
Value.CopyDocument()Copy a populated document for editing or interoperability.
Value.Kind()Report what the value holds.
Value.MarshalJSON()Encode the value as JSON.
Value.NumberValue()Public method Value.NumberValue from github.com/riducms/ridu/store.
Value.CopyObject()Create a mutable copy of an object field map.
Value.UnmarshalJSON()Decode any JSON value into a Value.
Value.CopyList()Create a mutable slice containing the list items.
Value.AppendJSON()AppendJSON appends the encoding MarshalJSON returns to dst, so a caller can encode many values into one buffer. It returns nil and the encoding/json error when value contains a non-finite number or an unencodable time.
Value.Elements()Iterate immutable list items in order without making a slice.
Value.Entries()Iterate immutable object members without copying the map.
Value.Get()Read an immutable object child without copying its container.
Value.IsZero()Report whether the value is the zero Value, which holds no data.
Value.Len()Count direct object members or list items without copying.
Value.ListItem()Read one immutable list item without copying the list.
Value.Lookup()Read an immutable object child and report whether the key exists.
Value.SameBacking()Recognize retained immutable sources before repeating derived work.
Value.WithListItem()Replace one list item while sharing unchanged immutable items.
Value.WithMembers()WithMembers returns an object with members added or replaced, sharing the other immutable members with the original. It copies the object's map once, where CopyObject followed by Object would copy it twice. It returns the original value and false for a non-object value. Existing values and retained snapshots are never mutated.