Documentation ¶
Index ¶
- Variables
- func IndexOf(array interface{}, value interface{}) int
- func Init()
- func IsArray(obj interface{}) bool
- func IsBool(obj interface{}) bool
- func IsBreak(value JsonType) bool
- func IsContinue(value JsonType) bool
- func IsEqualArray(a, b []JsonType) bool
- func IsEqualObject(a, b utils.NavigableMap[string, JsonType]) bool
- func IsJsonPath(obj interface{}) bool
- func IsNull(i interface{}) bool
- func IsNumber(obj interface{}) bool
- func IsObject(obj interface{}) bool
- func IsReservedKey(k string) bool
- func IsReturn(value JsonType) bool
- func IsSemver(obj interface{}) bool
- func IsSignal(value interface{}) bool
- func IsString(obj interface{}) bool
- func ToPrettyString(obj interface{}) string
- func ToString(obj interface{}) string
- func TypeName(obj interface{}) string
- type JsonAction
- type JsonArray
- func AsArray(obj interface{}) *JsonArray
- func CreateRange(start, end int32) *JsonArray
- func DeepCopyArray(object *JsonArray) *JsonArray
- func DeleteNullsFromArray(array *JsonArray) *JsonArray
- func MergeArray(template, parent *JsonArray, keepOverrides bool, path string) *JsonArray
- func NewJsonArray() *JsonArray
- func ParseJsonArray(str []byte) (*JsonArray, error)
- func (t *JsonArray) Add(i JsonType) JsonType
- func (t *JsonArray) Append(v ...JsonType) *JsonArray
- func (t *JsonArray) BoolValue() bool
- func (t *JsonArray) Equals(value JsonType) bool
- func (t *JsonArray) Index(i JsonType) (JsonType, error)
- func (t *JsonArray) LessThan(other JsonType) (bool, error)
- func (t *JsonArray) Negate() JsonType
- func (t *JsonArray) Parent() JsonType
- func (t *JsonArray) ParentIndex() JsonType
- func (t *JsonArray) Prepend(v ...JsonType) *JsonArray
- func (t *JsonArray) Remove(i *JsonNumber) (JsonType, error)
- func (t *JsonArray) RemoveBack() (JsonType, error)
- func (t *JsonArray) RemoveFront() (JsonType, error)
- func (t *JsonArray) RemoveIf(i *JsonLambda) (JsonType, error)
- func (t *JsonArray) StringValue() string
- func (t *JsonArray) Unbox() interface{}
- func (t *JsonArray) UpdateParent(parent JsonType, parentIndex JsonType)
- type JsonBool
- func (t *JsonBool) Add(i JsonType) JsonType
- func (t *JsonBool) BoolValue() bool
- func (t *JsonBool) Equals(value JsonType) bool
- func (t *JsonBool) Index(i JsonType) (JsonType, error)
- func (t *JsonBool) LessThan(other JsonType) (bool, error)
- func (t *JsonBool) Negate() JsonType
- func (t *JsonBool) Parent() JsonType
- func (t *JsonBool) ParentIndex() JsonType
- func (t *JsonBool) StringValue() string
- func (t *JsonBool) Unbox() interface{}
- func (t *JsonBool) UpdateParent(parent JsonType, parentIndex JsonType)
- type JsonLambda
- func (t *JsonLambda) Add(i JsonType) JsonType
- func (t *JsonLambda) BoolValue() bool
- func (t *JsonLambda) Call(args ...JsonType) (JsonType, error)
- func (t *JsonLambda) Equals(JsonType) bool
- func (t *JsonLambda) Index(i JsonType) (JsonType, error)
- func (t *JsonLambda) LessThan(JsonType) (bool, error)
- func (t *JsonLambda) Negate() JsonType
- func (t *JsonLambda) Parent() JsonType
- func (t *JsonLambda) ParentIndex() JsonType
- func (t *JsonLambda) StringValue() string
- func (t *JsonLambda) Unbox() interface{}
- func (t *JsonLambda) UpdateParent(parent JsonType, parentIndex JsonType)
- type JsonNull
- func (t *JsonNull) Add(i JsonType) JsonType
- func (t *JsonNull) BoolValue() bool
- func (t *JsonNull) Equals(value JsonType) bool
- func (t *JsonNull) Index(i JsonType) (JsonType, error)
- func (t *JsonNull) LessThan(other JsonType) (bool, error)
- func (t *JsonNull) Negate() JsonType
- func (t *JsonNull) Parent() JsonType
- func (t *JsonNull) ParentIndex() JsonType
- func (t *JsonNull) StringValue() string
- func (t *JsonNull) Unbox() interface{}
- func (t *JsonNull) UpdateParent(parent JsonType, parentIndex JsonType)
- type JsonNumber
- func (t *JsonNumber) Add(i JsonType) JsonType
- func (t *JsonNumber) BoolValue() bool
- func (t *JsonNumber) Equals(value JsonType) bool
- func (t *JsonNumber) FloatValue() float64
- func (t *JsonNumber) Index(i JsonType) (JsonType, error)
- func (t *JsonNumber) IntValue() int32
- func (t *JsonNumber) LessThan(other JsonType) (bool, error)
- func (t *JsonNumber) Negate() JsonType
- func (t *JsonNumber) Parent() JsonType
- func (t *JsonNumber) ParentIndex() JsonType
- func (t *JsonNumber) StringValue() string
- func (t *JsonNumber) Unbox() interface{}
- func (t *JsonNumber) UpdateParent(parent JsonType, parentIndex JsonType)
- type JsonObject
- func AsObject(obj interface{}) *JsonObject
- func DeepCopyObject(object *JsonObject) *JsonObject
- func DeleteNulls(object *JsonObject) *JsonObject
- func MergeObject(template, parent *JsonObject, keepOverrides bool, path string) *JsonObject
- func NewJsonObject() *JsonObject
- func ParseJsonObject(str []byte) (*JsonObject, error)
- func (t *JsonObject) Add(i JsonType) JsonType
- func (t *JsonObject) BoolValue() bool
- func (t *JsonObject) ContainsKey(key string) bool
- func (t *JsonObject) Equals(value JsonType) bool
- func (t *JsonObject) Get(key string) JsonType
- func (t *JsonObject) Index(i JsonType) (JsonType, error)
- func (t *JsonObject) IsEmpty() bool
- func (t *JsonObject) Keys() []string
- func (t *JsonObject) LessThan(value JsonType) (bool, error)
- func (t *JsonObject) Negate() JsonType
- func (t *JsonObject) Parent() JsonType
- func (t *JsonObject) ParentIndex() JsonType
- func (t *JsonObject) Put(key string, value JsonType)
- func (t *JsonObject) Remove(key string)
- func (t *JsonObject) Size() int
- func (t *JsonObject) StringValue() string
- func (t *JsonObject) Unbox() interface{}
- func (t *JsonObject) UpdateParent(parent JsonType, parentIndex JsonType)
- func (t *JsonObject) Values() []JsonType
- type JsonPath
- func (t *JsonPath) Add(i JsonType) JsonType
- func (t *JsonPath) BoolValue() bool
- func (t *JsonPath) Equals(value JsonType) bool
- func (t *JsonPath) Get(x JsonType) (JsonType, error)
- func (t *JsonPath) Index(i JsonType) (JsonType, error)
- func (t *JsonPath) IsEmpty() bool
- func (t *JsonPath) LessThan(other JsonType) (bool, error)
- func (t *JsonPath) Negate() JsonType
- func (t *JsonPath) Parent() JsonType
- func (t *JsonPath) ParentIndex() JsonType
- func (t *JsonPath) ParentPath() *JsonPath
- func (t *JsonPath) Set(x, value JsonType) (JsonType, error)
- func (t *JsonPath) SetIndex(i, value JsonType) error
- func (t *JsonPath) StringValue() string
- func (t *JsonPath) Unbox() interface{}
- func (t *JsonPath) UpdateParent(parent JsonType, parentIndex JsonType)
- type JsonSignal
- func (t *JsonSignal) Add(i JsonType) JsonType
- func (t *JsonSignal) BoolValue() bool
- func (t *JsonSignal) Equals(value JsonType) bool
- func (t *JsonSignal) Index(i JsonType) (JsonType, error)
- func (t *JsonSignal) LessThan(other JsonType) (bool, error)
- func (t *JsonSignal) Negate() JsonType
- func (t *JsonSignal) Parent() JsonType
- func (t *JsonSignal) ParentIndex() JsonType
- func (t *JsonSignal) StringValue() string
- func (t *JsonSignal) Unbox() interface{}
- func (t *JsonSignal) UpdateParent(parent JsonType, parentIndex JsonType)
- type JsonString
- func (t *JsonString) Add(i JsonType) JsonType
- func (t *JsonString) BoolValue() bool
- func (t *JsonString) Equals(value JsonType) bool
- func (t *JsonString) Index(index JsonType) (JsonType, error)
- func (t *JsonString) LessThan(other JsonType) (bool, error)
- func (t *JsonString) Negate() JsonType
- func (t *JsonString) Parent() JsonType
- func (t *JsonString) ParentIndex() JsonType
- func (t *JsonString) StringValue() string
- func (t *JsonString) Unbox() interface{}
- func (t *JsonString) UpdateParent(parent JsonType, parentIndex JsonType)
- type JsonType
- type Number
- type Semver
- func (t *Semver) Add(i JsonType) JsonType
- func (t *Semver) BoolValue() bool
- func (t *Semver) CompareTo(other *Semver) int
- func (t *Semver) Equals(value JsonType) bool
- func (t *Semver) Index(i JsonType) (JsonType, error)
- func (t *Semver) IsEmpty() bool
- func (t *Semver) LessThan(other JsonType) (bool, error)
- func (t *Semver) Negate() JsonType
- func (t *Semver) Parent() JsonType
- func (t *Semver) ParentIndex() JsonType
- func (t *Semver) StringValue() string
- func (t *Semver) Unbox() interface{}
- func (t *Semver) UpdateParent(parent JsonType, parentIndex JsonType)
- type SignalType
- type TypeDescriptor
Constants ¶
This section is empty.
Variables ¶
var Break = &JsonSignal{Value: Null, Type: SignalBreak}
var Continue = &JsonSignal{Value: Null, Type: SignalContinue}
var IdentityLambda = NewLambda(func(this *JsonLambda, args []JsonType) (JsonType, error) { if len(args) != 1 { return nil, burrito.WrappedErrorf("Identity lambda must have exactly 1 argument") } return args[0], nil }, "x=>x", []string{"x"}, []string{"x"})
var Null = &JsonNull{}
var TypeDescriptors []TypeDescriptor
Functions ¶
func IsArray ¶
func IsArray(obj interface{}) bool
IsArray returns true if the given interface is an array.
func IsBool ¶
func IsBool(obj interface{}) bool
IsBool returns true if the given interface is a boolean or a JsonBool.
func IsContinue ¶
func IsEqualArray ¶
IsEqualArray returns true if the given JSON arrays are equal.
func IsEqualObject ¶
func IsEqualObject(a, b utils.NavigableMap[string, JsonType]) bool
IsEqualObject returns true if the given JSON objects are equal.
func IsJsonPath ¶
func IsJsonPath(obj interface{}) bool
IsJsonPath returns true if the given interface is a semver object.
func IsNumber ¶
func IsNumber(obj interface{}) bool
IsNumber returns true if the given interface is a number.
func IsObject ¶
func IsObject(obj interface{}) bool
IsObject returns true if the given interface is an object.
func IsReservedKey ¶
func IsSemver ¶
func IsSemver(obj interface{}) bool
IsSemver returns true if the given interface is a semver object.
func IsString ¶
func IsString(obj interface{}) bool
IsString returns true if the given interface is a string.
func ToPrettyString ¶
func ToPrettyString(obj interface{}) string
ToPrettyString converts an interface to a string. In case of an object or array, it will be pretty printed.
Types ¶
type JsonAction ¶
type JsonAction int
JsonAction is an enum for the different actions that can be performed via jsonte.
const ( Value JsonAction = iota Iteration Literal Predicate )
func (JsonAction) String ¶
func (a JsonAction) String() string
String returns a string representation of the given JsonAction.
type JsonArray ¶
type JsonArray struct { Value []JsonType // contains filtered or unexported fields }
func AsArray ¶
func AsArray(obj interface{}) *JsonArray
AsArray returns the given interface as a JSON array.
func CreateRange ¶
CreateRange creates a range of numbers from start to end as a JSON array.
func DeepCopyArray ¶
DeepCopyArray creates a deep copy of the given JSON array.
func DeleteNullsFromArray ¶
DeleteNullsFromArray removes all keys inside elements of JSON object type with null values from the given JSON array.
func MergeArray ¶
MergeArray merges two JSON arrays into a new JSON array.
func NewJsonArray ¶
func NewJsonArray() *JsonArray
func ParseJsonArray ¶
ParseJsonArray parses a JSON string into a JSON array. It includes support for comments and detects common syntax errors.
func (*JsonArray) ParentIndex ¶
func (*JsonArray) RemoveBack ¶
func (*JsonArray) RemoveFront ¶
func (*JsonArray) StringValue ¶
func (*JsonArray) UpdateParent ¶
type JsonBool ¶
type JsonBool struct { Value bool // contains filtered or unexported fields }
JsonBool is a struct that represents a boolean JSON value.
func (*JsonBool) LessThan ¶
LessThan compares the JsonBool with another JsonType, returning true if the boolean is false and the other value is true.
func (*JsonBool) ParentIndex ¶
func (*JsonBool) StringValue ¶
StringValue returns the string representation of the JsonBool.
func (*JsonBool) Unbox ¶
func (t *JsonBool) Unbox() interface{}
Unbox returns the JsonBool as a native Go bool.
func (*JsonBool) UpdateParent ¶
type JsonLambda ¶
type JsonLambda struct { Value func(this *JsonLambda, args []JsonType) (JsonType, error) Arguments []string UsedVariables []string String string }
JsonLambda is a struct that represents a lambda value.
func NewLambda ¶
func NewLambda(value func(this *JsonLambda, args []JsonType) (JsonType, error), stringValue string, vars, args []string) *JsonLambda
func (*JsonLambda) Add ¶
func (t *JsonLambda) Add(i JsonType) JsonType
func (*JsonLambda) BoolValue ¶
func (t *JsonLambda) BoolValue() bool
func (*JsonLambda) Equals ¶
func (t *JsonLambda) Equals(JsonType) bool
func (*JsonLambda) Negate ¶
func (t *JsonLambda) Negate() JsonType
func (*JsonLambda) Parent ¶
func (t *JsonLambda) Parent() JsonType
func (*JsonLambda) ParentIndex ¶
func (t *JsonLambda) ParentIndex() JsonType
func (*JsonLambda) StringValue ¶
func (t *JsonLambda) StringValue() string
func (*JsonLambda) Unbox ¶
func (t *JsonLambda) Unbox() interface{}
func (*JsonLambda) UpdateParent ¶
func (t *JsonLambda) UpdateParent(parent JsonType, parentIndex JsonType)
type JsonNull ¶
type JsonNull struct {
// contains filtered or unexported fields
}
JsonNull is a struct that represents a null value.
func NullWithParent ¶
func (*JsonNull) ParentIndex ¶
func (*JsonNull) StringValue ¶
func (*JsonNull) UpdateParent ¶
type JsonNumber ¶
JsonNumber is a struct that represents a number, that can be either integer or decimal.
func AsNumber ¶
func AsNumber(obj interface{}) *JsonNumber
AsNumber converts an interface to a JSON number.
func (*JsonNumber) Add ¶
func (t *JsonNumber) Add(i JsonType) JsonType
func (*JsonNumber) BoolValue ¶
func (t *JsonNumber) BoolValue() bool
func (*JsonNumber) Equals ¶
func (t *JsonNumber) Equals(value JsonType) bool
func (*JsonNumber) FloatValue ¶
func (t *JsonNumber) FloatValue() float64
func (*JsonNumber) IntValue ¶
func (t *JsonNumber) IntValue() int32
func (*JsonNumber) Negate ¶
func (t *JsonNumber) Negate() JsonType
func (*JsonNumber) Parent ¶
func (t *JsonNumber) Parent() JsonType
func (*JsonNumber) ParentIndex ¶
func (t *JsonNumber) ParentIndex() JsonType
func (*JsonNumber) StringValue ¶
func (t *JsonNumber) StringValue() string
func (*JsonNumber) Unbox ¶
func (t *JsonNumber) Unbox() interface{}
func (*JsonNumber) UpdateParent ¶
func (t *JsonNumber) UpdateParent(parent JsonType, parentIndex JsonType)
type JsonObject ¶
type JsonObject struct { Value *utils.NavigableMap[string, JsonType] StackValue *deque.Deque[*JsonObject] StackTarget *JsonObject // contains filtered or unexported fields }
func AsObject ¶
func AsObject(obj interface{}) *JsonObject
AsObject returns the given interface as a JSON object.
func DeepCopyObject ¶
func DeepCopyObject(object *JsonObject) *JsonObject
DeepCopyObject creates a deep copy of the given JSON object.
func DeleteNulls ¶
func DeleteNulls(object *JsonObject) *JsonObject
DeleteNulls removes all keys with null values from the given JSON object.
func MergeObject ¶
func MergeObject(template, parent *JsonObject, keepOverrides bool, path string) *JsonObject
MergeObject merges two JSON objects into a new JSON object. If the same value, that is not an object or an array exists in both objects, the value from the second object will be used.
func NewJsonObject ¶
func NewJsonObject() *JsonObject
func ParseJsonObject ¶
func ParseJsonObject(str []byte) (*JsonObject, error)
ParseJsonObject parses a JSON string into a JSON object. It includes support for comments and detects common syntax errors.
func (*JsonObject) Add ¶
func (t *JsonObject) Add(i JsonType) JsonType
func (*JsonObject) BoolValue ¶
func (t *JsonObject) BoolValue() bool
func (*JsonObject) ContainsKey ¶
func (t *JsonObject) ContainsKey(key string) bool
func (*JsonObject) Equals ¶
func (t *JsonObject) Equals(value JsonType) bool
func (*JsonObject) Get ¶
func (t *JsonObject) Get(key string) JsonType
func (*JsonObject) IsEmpty ¶
func (t *JsonObject) IsEmpty() bool
func (*JsonObject) Keys ¶
func (t *JsonObject) Keys() []string
func (*JsonObject) Negate ¶
func (t *JsonObject) Negate() JsonType
func (*JsonObject) Parent ¶
func (t *JsonObject) Parent() JsonType
func (*JsonObject) ParentIndex ¶
func (t *JsonObject) ParentIndex() JsonType
func (*JsonObject) Put ¶
func (t *JsonObject) Put(key string, value JsonType)
func (*JsonObject) Remove ¶
func (t *JsonObject) Remove(key string)
func (*JsonObject) Size ¶
func (t *JsonObject) Size() int
func (*JsonObject) StringValue ¶
func (t *JsonObject) StringValue() string
func (*JsonObject) Unbox ¶
func (t *JsonObject) Unbox() interface{}
func (*JsonObject) UpdateParent ¶
func (t *JsonObject) UpdateParent(parent JsonType, parentIndex JsonType)
func (*JsonObject) Values ¶
func (t *JsonObject) Values() []JsonType
type JsonPath ¶
type JsonPath struct { Path []JsonType // contains filtered or unexported fields }
JsonPath represents a simplified JSONPath
func AsJsonPath ¶
func AsJsonPath(obj interface{}) *JsonPath
func ParseJsonPath ¶
func (*JsonPath) ParentIndex ¶
func (*JsonPath) ParentPath ¶
func (*JsonPath) StringValue ¶
StringValue returns a string representation of the semantic version
func (*JsonPath) UpdateParent ¶
type JsonSignal ¶
type JsonSignal struct { Value JsonType Type SignalType }
func NewReturn ¶
func NewReturn(value JsonType) *JsonSignal
func (*JsonSignal) Add ¶
func (t *JsonSignal) Add(i JsonType) JsonType
func (*JsonSignal) BoolValue ¶
func (t *JsonSignal) BoolValue() bool
func (*JsonSignal) Equals ¶
func (t *JsonSignal) Equals(value JsonType) bool
func (*JsonSignal) Negate ¶
func (t *JsonSignal) Negate() JsonType
func (*JsonSignal) Parent ¶
func (t *JsonSignal) Parent() JsonType
func (*JsonSignal) ParentIndex ¶
func (t *JsonSignal) ParentIndex() JsonType
func (*JsonSignal) StringValue ¶
func (t *JsonSignal) StringValue() string
func (*JsonSignal) Unbox ¶
func (t *JsonSignal) Unbox() interface{}
func (*JsonSignal) UpdateParent ¶
func (t *JsonSignal) UpdateParent(parent JsonType, parentIndex JsonType)
type JsonString ¶
type JsonString struct { Value string // contains filtered or unexported fields }
JsonString is a struct that represents a number, that can be either integer or decimal.
func AsString ¶
func AsString(obj interface{}) *JsonString
AsString converts an interface to a string.
func NewString ¶
func NewString(value string) *JsonString
func (*JsonString) Add ¶
func (t *JsonString) Add(i JsonType) JsonType
func (*JsonString) BoolValue ¶
func (t *JsonString) BoolValue() bool
func (*JsonString) Equals ¶
func (t *JsonString) Equals(value JsonType) bool
func (*JsonString) Negate ¶
func (t *JsonString) Negate() JsonType
func (*JsonString) Parent ¶
func (t *JsonString) Parent() JsonType
func (*JsonString) ParentIndex ¶
func (t *JsonString) ParentIndex() JsonType
func (*JsonString) StringValue ¶
func (t *JsonString) StringValue() string
func (*JsonString) Unbox ¶
func (t *JsonString) Unbox() interface{}
func (*JsonString) UpdateParent ¶
func (t *JsonString) UpdateParent(parent JsonType, parentIndex JsonType)
type JsonType ¶
type JsonType interface { // StringValue returns the value as a string. StringValue() string // BoolValue returns the number as a boolean. BoolValue() bool // Equals returns true if the value is equal to the given value. Equals(value JsonType) bool // LessThan returns true if the value is less than the given value. LessThan(value JsonType) (bool, error) // Unbox returns the value without any containers. Unbox() interface{} // Negate returns the value negated with a minus operator. Negate() JsonType // Index returns the value at the given index. Index(index JsonType) (JsonType, error) // Add returns the sum of the value and the given value. Add(index JsonType) JsonType // Parent returns the parent of the value or nil. Parent() JsonType // ParentIndex returns the index of the value in the parent or nil. ParentIndex() JsonType // UpdateParent updates the parent of the value. UpdateParent(parent JsonType, parentIndex JsonType) }
type Number ¶
type Number interface { // IntValue returns the number as an integer. IntValue() int // FloatValue returns the number as a float. FloatValue() float64 }
Number is an interface that represents a number, that can be either integer or decimal.
type Semver ¶
Semver represents a semantic version
func ParseSemverArray ¶
ParseSemverArray parses an array representation of a semantic version
func ParseSemverString ¶
ParseSemverString parses a string representation of a semantic version
func (*Semver) CompareTo ¶
CompareTo compares two semantic versions. Returns 0 if they are equal, -1 if the receiver is less than the argument, and 1 if the receiver is greater than the argument.
func (*Semver) ParentIndex ¶
func (*Semver) StringValue ¶
StringValue returns a string representation of the semantic version
func (*Semver) UpdateParent ¶
type SignalType ¶
type SignalType int
const ( SignalReturn SignalType = iota SignalBreak SignalContinue )