Documentation
¶
Index ¶
- Variables
- type Function
- type Indexer
- type Kind
- type List
- type Map
- type Mapper
- type Value
- func Array(v Indexer) Value
- func Bool(v bool) Value
- func Func(fn func(...Value) (Value, error)) Value
- func MustMap(kvs ...Value) Value
- func NewList(v ...Value) Value
- func NewMap(kvs ...Value) (Value, error)
- func Null() Value
- func Number[T ~int | ~int64 | ~uint64 | ~float64](v T) Value
- func Object(v Mapper) Value
- func ParseNumber(v string) (Value, error)
- func ParseString(v string) (Value, error)
- func String(v string) Value
- func (v Value) Add(x Value) (Value, error)
- func (v Value) Attr(name string) (Value, error)
- func (v Value) Bool() (bool, error)
- func (v Value) Call(args ...Value) (Value, error)
- func (v Value) Divide(x Value) (Value, error)
- func (v Value) Equal(other Value) Value
- func (v Value) Float() (float64, error)
- func (v Value) Get(key Value) (Value, error)
- func (v Value) GreaterThan(other Value) Value
- func (v Value) GreaterThanEqual(other Value) Value
- func (v Value) HasMarks(marks uint16) bool
- func (v Value) Index(i int) (Value, error)
- func (v Value) Indexer() (Indexer, error)
- func (v Value) Int64() (int64, error)
- func (v Value) Kind() Kind
- func (v Value) Len() (int, error)
- func (v Value) LessThan(other Value) Value
- func (v Value) LessThanEqual(other Value) Value
- func (v Value) Mapper() (Mapper, error)
- func (v Value) Marks(recursive bool) uint16
- func (v Value) MarshalJSON() ([]byte, error)
- func (v Value) Modulo(x Value) (Value, error)
- func (v Value) Multiply(x Value) (Value, error)
- func (v Value) Negate() (Value, error)
- func (v Value) Not() Value
- func (v Value) String() string
- func (v Value) Subtract(x Value) (Value, error)
- func (v Value) Truthy() bool
- func (v *Value) UnmarshalJSON(data []byte) error
- func (v Value) WithMarks(marks uint16) Value
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Indexer ¶
type Indexer interface {
Get(Value) (Value, error)
Values() iter.Seq[Value]
Len() int
Index(int) (Value, error)
All() iter.Seq2[int, Value]
WithMarks(marks uint16) Indexer
}
Indexer is an interface used to represent array types.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List implements Indexer and is the default for the array type.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map implements Mapper and is the default for the object type.
type Mapper ¶
type Mapper interface {
Get(Value) (Value, error)
Values() iter.Seq[Value]
Len() int
Attr(string) (Value, error)
All() iter.Seq2[Value, Value]
Keys() iter.Seq[Value]
WithMarks(marks uint16) Mapper
}
Mapper is an interface used to represent objects types.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value represents a value of the following types: string, number, bool, object, array, null, func
func MustMap ¶
MustMap creates a new ordered map by passing (key, value, key, value)
This function panics if there's an odd number of elements passed, or if a key value is not a String.
func ParseNumber ¶
ParseNumber parses a string number and returns a Value with of kind Number.
func ParseString ¶
ParseString parses a literal string. It's similar to strconv.Unquote.
func (Value) Get ¶
Get returns either an attribute or index value.
The key can therefore be a number or string.
func (Value) GreaterThan ¶
GreaterThan returns true if v is greater than other.
func (Value) GreaterThanEqual ¶
GreaterThanEqual returns true if v is greater than or equal to other.
func (Value) LessThanEqual ¶
LessThanEqual returns true if v is less than or equal to other.
func (Value) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (Value) Negate ¶
Negate negates the value.
For boolean values: !value For number values: -value
func (Value) String ¶
String returns a string representation of the value.
For values that are of kind String, this returns the actual string value.
Object and Array kinds are serialized to JSON.
func (Value) Truthy ¶
Truthy returns if the value is "truthy" depending on the type:
bool: true if true string: true if length > 0 number: true if value > 0 object: true if length > 0 array: true of length > 0 null: false
func (*Value) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.