Documentation
¶
Index ¶
- func AsArray(obj interface{}) []interface{}
- func AsObject(obj interface{}) map[string]interface{}
- func CreateRange(start, end int32) []interface{}
- func DeepCopyArray(object []interface{}) []interface{}
- func DeepCopyObject(object map[string]interface{}) map[string]interface{}
- func DeleteNulls(object map[string]interface{}) map[string]interface{}
- func DeleteNullsFromArray(array []interface{}) []interface{}
- func IndexOf[T any](object []T, value T) int
- func IsArray(obj interface{}) bool
- func IsEqual(a, b interface{}) bool
- func IsEqualArray(a, b []interface{}) bool
- func IsEqualObject(a, b map[string]interface{}) bool
- func IsNumber(obj interface{}) bool
- func IsObject(obj interface{}) bool
- func IsSemver(obj interface{}) bool
- func MergeArray(template, parent []interface{}) []interface{}
- func MergeObject(template, parent map[string]interface{}) map[string]interface{}
- func ToBoolean(obj interface{}) bool
- func ToString(obj interface{}) string
- func UnescapeString(str string) string
- func UnwrapContainers(obj interface{}) interface{}
- type JsonFunction
- type JsonNumber
- type Number
- type Semver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsArray ¶
func AsArray(obj interface{}) []interface{}
AsArray returns the given interface as a JSON array.
func AsObject ¶
func AsObject(obj interface{}) map[string]interface{}
AsObject returns the given interface as a JSON object.
func CreateRange ¶
func CreateRange(start, end int32) []interface{}
CreateRange creates a range of numbers from start to end as a JSON array.
func DeepCopyArray ¶
func DeepCopyArray(object []interface{}) []interface{}
DeepCopyArray creates a deep copy of the given JSON array.
func DeepCopyObject ¶
DeepCopyObject creates a deep copy of the given JSON object.
func DeleteNulls ¶
DeleteNulls removes all keys with null values from the given JSON object.
func DeleteNullsFromArray ¶
func DeleteNullsFromArray(array []interface{}) []interface{}
DeleteNullsFromArray removes all keys inside elements of JSON object type with null values from the given JSON array.
func IsArray ¶
func IsArray(obj interface{}) bool
IsArray returns true if the given interface is an array.
func IsEqual ¶
func IsEqual(a, b interface{}) bool
IsEqual returns true if the given interfaces are equal.
func IsEqualArray ¶
func IsEqualArray(a, b []interface{}) bool
IsEqualArray returns true if the given JSON arrays are equal.
func IsEqualObject ¶
IsEqualObject returns true if the given JSON objects are equal.
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 IsSemver ¶
func IsSemver(obj interface{}) bool
IsSemver returns true if the given interface is a semver object.
func MergeArray ¶
func MergeArray(template, parent []interface{}) []interface{}
MergeArray merges two JSON arrays into a new JSON array.
func MergeObject ¶
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 UnescapeString ¶
UnescapeString removes quotes and unescapes a string.
func UnwrapContainers ¶
func UnwrapContainers(obj interface{}) interface{}
UnwrapContainers removes all containers from the given interface. Currently only unpacks JsonNumber into an actual number with correct type.
Types ¶
type JsonFunction ¶
type JsonFunction func(args []interface{}) (interface{}, error)
JsonFunction is a function that can be executed.
type JsonNumber ¶
JsonNumber is a struct that represents a number, that can be either integer or decimal.
func ToNumber ¶
func ToNumber(obj interface{}) JsonNumber
ToNumber converts an interface to a JSON number.
func (JsonNumber) BoolValue ¶
func (n JsonNumber) BoolValue() bool
func (JsonNumber) FloatValue ¶
func (n JsonNumber) FloatValue() float64
func (JsonNumber) IntValue ¶
func (n JsonNumber) IntValue() int32
func (JsonNumber) StringValue ¶
func (n JsonNumber) StringValue() string
type Number ¶
type Number interface { // IntValue returns the number as an integer. IntValue() int // FloatValue returns the number as a float. FloatValue() float64 // BoolValue returns the number as a boolean. BoolValue() bool // StringValue returns the number as a string. StringValue() string }
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.