anytype

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2025 License: LGPL-2.1 Imports: 12 Imported by: 1

README

AnyType

AnyType is a Go library providing dynamic data structures with JSON support. It contains a number of advanced features with API inspired by Java collections.

It supports following data types compatible with JSON standard:

  • nil (null)
  • object
  • list (array)
  • string
  • boolean
  • integer (number)
  • float (number)

Types can be referenced by the Type enum (e.g. TypeNil, TypeObject, ...). If the value does not exist, its type is considered TypeUndefined. Attempting to access an undefined value will cause a panic.

AnyType also allows usage of so-called "tree form" for accessing values. It is a string using hash for list elements and dot for object fields. For example #1.a.b#4 or .d.c#5#0.

The library is tested with 100% coverage.

Objects

Object is an unordered set of key-value pairs, the keys are of type string. The default implementation is based on built-in Go maps. It is possible to make custom implementations by implementing the Object interface.

Constructors
  • NewObject(values ...any) Object - initial object values are specified as key value pairs. The function panics if an odd number of arguments is given,
emptyObject := anytype.NewObject()
object := anytype.NewObject(
    "number", 1,
    "string", "test",
    "bool", true,
    "null", nil,
)
  • NewObjectFrom(dict any) Object - object can be also created from a given Go map. Any map with string for keys and a compatible type (including any) for values can be used,
object := anytype.NewObjectFrom(map[string]int{
	"first": 1,
	"second": 2,
    "third": 3,
})
  • ParseObject(json string) (Object, error) - loads an object from a JSON string,
object, err := anytype.ParseObject(`{"first":1,"second":2,"third":3}`)
if err != nil {
    // ...
}
  • ParseFile(path string) (Object, error) - loads an object from an UTF-8 encoded JSON file.
object, err := anytype.ParseFile("file.json")
if err != nil {
    // ...
}
Manipulation With Fields
  • Set(values ...any) Object - multiple new values can be set as key-value pairs, analogically to the constructor,
object.Set(
    "first", 1,
    "second", 2, 
)
  • Unset(keys ...string) Object - removes the given keys from the object,
object.Unset("first", "second")
  • Clear() Object - removes all keys from the object.
object.Clear()
Getting Fields
  • Universal getter (requires type assertion),
nested := object.Get("nested").(anytype.Object)
list := object.Get("list").(anytype.List)
str := object.Get("str").(string)
boolean := object.Get("boolean").(bool)
integer := object.Get("integer").(int)
float := object.Get("float").(float64)
  • type-specific getters.
nested := object.GetObject("nested")
list := object.GetList("list")
str := object.GetString("str")
boolean := object.GetBool("boolean")
integer := object.GetInt("integer")
float := object.GetFloat("float")
Type Check
  • TypeOf(key string) Type.
if object.TypeOf("integer") == anytype.TypeInt {
    // ...
}
Export
  • String() string - exports the object into a JSON string,
fmt.Println(object.String())
  • FormatString(indent int) string - exports the object into a well-arranged JSON string with the given indentation,
fmt.Println(object.FormatString(4))
  • Dict() map[string]any - exports the object into a Go map,
var dict map[string]any
dict = object.Dict()
  • NativeDict() map[string]any - recursively exports the object into a Go map (nested objects and lists are converted too),
var dict map[string]any
dict = object.NativeDict()
  • Keys() List - exports all keys of the object into an AnyType list,
var keys anytype.List
keys = object.Keys()
  • Values() List - exports all values of the object into an AnyType list.
var values anytype.List
values = object.Values()
Features Over Whole Object
  • Clone() Object - performs a deep copy of the object,
copy := object.Clone()
  • Count() int - returns a number of fileds of the object,
for i := 0; i < object.Count(); i++ {
    // ...
}
  • Empty() bool - checks whether the object is empty,
if object.Empty() {
    // ...
}
  • Equals(another Object) bool - checks whether all fields of the object are equal to the fields of another object,
if object.Equals(another) {
    // ...
}
  • Merge(another Object) Object - merges two objects together,
merged := object.Merge(another)
  • Pluck(keys ...string) Object - creates a new object containing only the selected keys from existing object,
plucked := object.Pluck("first", "second")
  • Contains(elem any) bool - checks whether the object contains a certain value,
if object.Contains(1) {
    // ...
}
  • KeyOf(elem any) string - returns any key containing the given value. It panics if the object does not contain the value,
first := object.KeyOf(1)
  • KeyExists(key string) bool - checks whether a key exists within the object.
if object.KeyExists("first") {
    // ...
}
ForEaches
  • ForEach(function func(string, any)) Object - executes a given function over an every field of the object,
object.ForEach(func(key string, value any) {
    // ...
})
  • ForEachValue(function func(any)) Object - ForEach without the key variable within the anonymous function,
object.ForEachValue(func(value any) {
    // ...
})
  • type-specific ForEaches - anonymous function is only executed over values of the corresponding type.
object.ForEachObject(func(object anytype.Object) {
    // ...
})
object.ForEachList(func(list anytype.List) {
    // ...
})
object.ForEachString(func(str string) {
    // ...
})
object.ForEachBool(func(object bool) {
    // ...
})
object.ForEachInt(func(integer int) {
    // ...
})
object.ForEachFloat(func(float float64) {
    // ...
})
Mappings
  • Map(function func(string, any) any) Object - returns a new object with fields modified by a given function,
mapped := object.Map(func(key string, value any) any {
    // ...
	return newValue
})
  • MapValues(function func(any) any) Object - Map without the key variable within the anonymous function,
mapped := object.MapValues(func(value any) any {
    // ...
	return newValue
})
  • type-specific Maps - selects only fields of the corresponding type.
objects := object.MapObjects(func(object anytype.Object) any {
    // ...
	return newValue
})
lists := object.MapLists(func(list anytype.List) any {
    // ...
	return newValue
})
strs := object.MapStrings(func(str string) any {
    // ...
	return newValue
})
booleans := object.MapBools(func(boolean bool) any {
    // ...
	return newValue
})
integers := object.MapInts(func(integer int) any {
    // ...
	return newValue
})
floats := object.MapFloats(func(float float64) any {
    // ...
	return newValue
})
Asynchronous
  • ForEachAsync(function func(string, any)) Object - performs the ForEach parallelly,
object.ForEachAsync(func(key string, value any) {
    // ...
})
  • MapAsync(function func(string, any) any) Object - performs the Map parallelly.
mapped := object.MapAsync(func(key string, value any) any {
    // ...
	return newValue
})
Tree Form
  • GetTF(tf string) any - returns a value specified by the given tree form string,
value := object.GetTF(".first#2")
  • SetTF(tf string, value any) Object - sets a value on the path specified by the given tree form string,
object.SetTF(".first#2", 2)
  • UnsetTF(tf string) Object - unsets a value on the path specified by the given tree form string,
object.UnsetTF(".first#2")
  • TypeOfTF(tf string) Type - returns a type of the field specified by the given tree form string.
if object.TypeOfTF(".first#2") == anytype.TypeInt {
    // ...
}

Lists

List is an ordered sequence of elements. The default implementation is based on built-in Go slices. It is possible to make custom implementations by implementing the List interface.

Constructors
  • NewList(values ...any) List - initial list elements could be given as variadic arguments,
emptyList := anytype.NewList()
list := anytype.NewList(1, "test", true, nil)
  • NewListOf(value any, count int) List - creates a list of n repeated values,
list := anytype.NewListOf(nil, 10)
  • NewListFrom(slice any) List - creates a list from a given Go slice. Any slice of a compatible type (including any) can be used,
list := anytype.NewListFrom([]int{1, 2, 3})
  • ParseList(json string) (List, error) - loads a list from a JSON string,
list, err := anytype.ParseList(`[1, 2, 3]`)
if err != nil {
    // ...
}
Manipulation With Elements
  • Add(val ...any) List - adds any amount of new elements to the list,
list.Add(1, 2, 3)
  • Insert(index int, value any) List - inserts a new element to a specific position in the list,
list.Insert(1, 1.5)
  • Replace(index int, value any) List - replaces an existing element,
list.Replace(1, "2")
  • Delete(index ...int) List - removes specified elements,
list.Delete(1, 2)
  • Pop() List - removes the last element from the list,
list.Pop()
  • Clear() List - removes all elements from the list.
list.Clear()
Getting Elements
  • Universal getter (requires type assertion),
object := list.Get(0).(anytype.Object)
nested := list.Get(1).(anytype.List)
str := list.Get(2).(string)
boolean := list.Get(3).(bool)
integer := list.Get(4).(int)
float := list.Get(5).(float64)
  • type-specific getters.
object := list.GetObject(0)
nested := list.GetList(1)
str := list.GetString(2)
boolean := list.GetBool(3)
integer := list.GetInt(4)
float := list.GetFloat(5)
Type Check
  • TypeOf(index int) Type.
if list.TypeOf(0) == anytype.TypeInt {
    // ...
}
Export
  • String() string - exports the list into a JSON string,
fmt.Println(list.String())
  • FormatString(indent int) string - exports the list into a well-arranged JSON string with the given indentation,
fmt.Println(list.FormatString(4))
  • Slice() []any - exports the list into a Go slice,
var slice []any
slice = list.Slice()
  • NativeSlice() []any - recursively exports the list into a Go slice (nested objects and lists are converted too),
var slice []any
slice = list.NativeSlice()
  • export into type-specific slices - values of other types are ignored,
var objects []anytype.Object
objects = list.ObjectSlice()
var lists []anytype.List
lists = list.ListSlice()
var strs []string
strs = list.StringSlice()
var bools []bool
bools = list.BoolSlice()
var ints []int
ints = list.IntSlice()
var floats []float64
floats = list.FloatSlice()
Features Over Whole List
  • Clone() List - performs a deep copy of the list,
copy := list.Clone()
  • Count() int - returns a number of elements in the list,
for i := 0; i < list.Count(); i++ {
    // ...
}
  • Empty() bool - checks whether the list is empty,
if list.Empty() {
    // ...
}
  • Equals(another List) bool - checks whether all elements of the list are equal to the elements of another list,
if list.Equals(another) {
    // ...
}
  • Concat(another List) List - concates two lists together,
concated := list.Concat(another)
  • SubList(start int, end int) List - cuts a part of the list,
subList := list.SubList(1, 3)
  • Contains(elem any) bool - checks whether the list contains a certain value,
if list.Contains("value") {
    // ...
}
  • IndexOf(elem any) int - returns a position of the first occurrence of the given value,
elem := list.IndexOf("value")
  • Sort() List - sorts the elements in the list. The sorting type is determined by the first element which has to be either string, int or float,
list.Sort()
  • Reverse() List - reverses the list,
list.Reverse()
Checks For Homogeneity
  • AllNumeric() bool - checks if all elements are numbers (ints or floats),
if list.AllNumeric() {
    // ...
}
  • type-specific asserts.
if list.AllObjects() {
    // ...
} else if list.AllLists() {
    // ...
} else if list.AllStrings() {
    // ...
} else if list.AllBools() {
    // ...
} else if list.AllInts() {
    // ...
} else if list.AllFloats() {
    // ...
} else {
    // ...
}
ForEaches
  • ForEach(function func(int, any)) List - executes a given function over an every element of the list,
list.ForEach(func(index int, value any) {
    // ...
})
  • ForEachValue(function func(any)) List - ForEach without the index variable within the anonymous function,
list.ForEachValue(func(value any) {
    // ...
})
  • type-specific ForEaches - anonymous function is only executed over values of the corresponding type.
list.ForEachObject(func(object anytype.Object) {
    // ...
})
list.ForEachList(func(list anytype.List) {
    // ...
})
list.ForEachString(func(str string) {
    // ...
})
list.ForEachBool(func(object bool) {
    // ...
})
list.ForEachInt(func(integer int) {
    // ...
})
list.ForEachFloat(func(float float64) {
    // ...
})
Mappings
  • Map(function func(int, any) any) List - returns a new list with elements modified by a given function,
mapped := list.Map(func(index int, value any) any {
    // ...
	return newValue
})
  • MapValues(function func(any) any) List - Map without the index variable within the anonymous function,
mapped := list.MapValues(func(value any) any {
    // ...
	return newValue
})
  • type-specific Maps - selects only elements of the corresponding type.
objects := list.MapObjects(func(object anytype.Object) any {
    // ...
	return newValue
})
lists := list.MapLists(func(list anytype.List) any {
    // ...
	return newValue
})
strs := list.MapStrings(func(str string) any {
    // ...
	return newValue
})
booleans := list.MapBools(func(boolean bool) any {
    // ...
	return newValue
})
integers := list.MapInts(func(integer int) any {
    // ...
	return newValue
})
floats := list.MapFloats(func(float float64) any {
    // ...
	return newValue
})
Reductions
  • Reduce(initial any, function func(any, any) any) any - reduces all elements in the list into a single value,
result := list.Reduce(0, func(sum, value any) any {
	return sum.(int) + value.(int)
})
  • type-specific Reductions - selects only elements of the corresponding type. Return value has to be of the same type.
result := list.ReduceStrings("", func(concated, value string) string {
	return concated + value
})
result := list.ReduceInts(0, func(sum, value int) int {
	return sum + value
})
result := list.ReduceFloats(0, func(sum, value float64) float64 {
	return sum + value
})
Filters
  • Filter(function func(any) bool) List - filters elements in the list based on a condition,
filtered := list.Filter(func(value any) bool {
    // ...
	return condition
})
  • type-specific Filters - filters only elements of the corresponding type.
objects := list.FilterObjects(func(value anytype.Object) bool {
    // ...
	return condition
})
lists := list.FilterLists(func(value anytype.List) bool {
    // ...
	return condition
})
strs := list.FilterStrings(func(value string) bool {
    // ...
	return condition
})
integers := list.FilterInts(func(value int) bool {
    // ...
	return condition
})
floats := list.FilterFloats(func(value float64) bool {
    // ...
	return condition
})
Numeric Operations
  • IntSum() int - computes a sum of all ints in the list (0 if no ints are present),
sum := list.IntSum()
  • Sum() float64 - compatible with both numeric types, returns float,
sum := list.Sum()
  • IntProd() int - computes a product of all ints in the list (1 if no ints are present),
product := list.IntProd()
  • Prod() float64 - compatible with both numeric types, returns float,
product := list.Prod()
  • Avg() float64 - computes an arithmetic mean of all numbers in the list (0 if no ints are present),
average := list.Avg()
  • IntMin() int - returns a minimum integer value in the list (0 if no ints are present),
minimum := list.IntMin()
  • Min() float64 - compatible with both numeric types, returns float,
minimum := list.Min()
  • IntMax() int - returns a maximum integer value in the list (0 if no ints are present),
maximum := list.IntMax()
  • Max() float64 - compatible with both numeric types, returns float,
maximum := list.Max()
Asynchronous
  • ForEachAsync(function func(int, any)) List - performs the ForEach parallelly,
list.ForEachAsync(func(index int, value any) {
    // ...
})
  • MapAsync(function func(int, any) any) List - performs the Map parallelly.
mapped := list.MapAsync(func(index int, value any) any {
    // ...
	return newValue
})
Tree Form
  • GetTF(tf string) any - returns a value specified by the given tree form string,
value := list.GetTF("#2.first")
  • SetTF(tf string, value any) List - sets a value on the path specified by the given tree form string,
list.SetTF("#2.first", 2)
  • UnsetTF(tf string) List - unsets a value on the path specified by the given tree form string,
list.UnsetTF("#2.first")
  • TypeOfTF(tf string) Type - returns a type of the element specified by the given tree form string.
if list.TypeOfTF("#2.first") == anytype.TypeInt {
    // ...
}

Derived Structures

AnyType supports inheritance and method overriding by defining custom structures with embedded object or list. As Go uses the embedded pointer as a receiver instead of the embedding structure, the pointer to the derived structure (so-called "ego pointer") has to be stored using the method Init(ptr Object)/Init(ptr List). When overriding a method, the ego pointer can be obtained with Ego() Object/Ego() List.

// Embeds an object
type Animal struct {
	anytype.Object
	name string
}

func NewAnimal(name string, age int) *Animal {
	ego := &Animal{
		Object: anytype.NewObject(
			"age", age,
		),
		name: name,
	}
	ego.Init(ego) // Ego pointer initialization
	return ego
}

// Method overriding
func (ego *Animal) Clear() anytype.Object {
	fmt.Fprintln(os.Stderr, "fields of an animal cannot be cleared")
	return ego.Ego() // Using stored pointer to return Animal instead of the embedded object
}

func (ego *Animal) Breathe() {
	fmt.Println("breathing")
}

// Inherits from animal, adds another field
type Dog struct {
	*Animal
	breed string
}

func NewDog(name string, age int, breed string) *Dog {
	ego := &Dog{
		Animal: NewAnimal(name, age),
		breed:  breed,
	}
	ego.Init(ego) // Ego pointer initialization
	return ego
}

// Method overriding
func (ego *Dog) Unset(keys ...string) anytype.Object {
	fmt.Fprintln(os.Stderr, "fields of a dog cannot be unset")
	return ego.Ego() // Using stored pointer to return Dog instead of object
}

func (ego *Dog) Bark() {
	fmt.Println("woof")
}

func main() {

	dog := NewDog("Rex", 2, "German Shepherd")

	// Methods from both Dog and Animal can be used
	dog.Breathe()
	dog.Bark()

    // Methods of the object can be used, too
	dog.Set("color", "black")

	// Printing the object inside
	fmt.Println(dog.String())

	// Both methods have been overridden
	dog.Unset("age")
	dog.Clear()

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

type List interface {

	/*
		Init initializes the ego pointer, which allows deriving.

		Parameters:
		  - ptr - ego pointer.
	*/
	Init(ptr List)

	/*
		Ego acquires the ego pointer previously set by Init.

		Returns:
		  - ego pointer.
	*/
	Ego() List

	/*
		Add adds new elements at the end of the list.

		Parameters:
		  - values... - any amount of elements to add.

		Returns:
		  - updated list.
	*/
	Add(val ...any) List

	/*
		Insert inserts a new element at the specified position in the list.

		Parameters:
		  - index - position where the element should be inserted,
		  - value - element to insert.

		Returns:
		  - updated list.
	*/
	Insert(index int, value any) List

	/*
		Replace replaces an existing element with a new one.

		Parameters:
		  - index - position of the element which should be replaced,
		  - value - new element.

		Returns:
		  - updated list.
	*/
	Replace(index int, value any) List

	/*
		Delete deletes the elements at the specified positions in the list.

		Parameters:
		  - indexes... - any amount of positions of the elements to delete.

		Returns:
		  - updated list.
	*/
	Delete(index ...int) List

	/*
		Pop deletes the last element in the list.

		Returns:
		  - updated list.
	*/
	Pop() List

	/*
		Clear deletes all elements in the list.

		Returns:
		  - updated list.
	*/
	Clear() List

	/*
		Get acquires an element at the specified position in the list.

		Parameters:
		  - index - position of the element to get.

		Returns:
		  - corresponding value (any type, has to be asserted).
	*/
	Get(index int) any

	/*
		GetObject acquires an object at the specified position in the list.
		Causes a panic if the element has another type.

		Parameters:
		  - index - position of the element to get.

		Returns:
		  - corresponding value asserted as object.
	*/
	GetObject(index int) Object

	/*
		GetList acquires a list at the specified position in the list.
		Causes a panic if the element has another type.

		Parameters:
		  - index - position of the element to get.

		Returns:
		  - corresponding value asserted as list.
	*/
	GetList(index int) List

	/*
		GetString acquires a string at the specified position in the list.
		Causes a panic if the element has another type.

		Parameters:
		  - index - position of the element to get.

		Returns:
		  - corresponding value asserted as string.
	*/
	GetString(index int) string

	/*
		GetBool acquires a boolean at the specified position in the list.
		Causes a panic if the element has another type.

		Parameters:
		  - index - position of the element to get.

		Returns:
		  - corresponding value asserted as bool.
	*/
	GetBool(index int) bool

	/*
		GetInt acquires an integer at the specified position in the list.
		Causes a panic if the element has another type.

		Parameters:
		  - index - position of the element to get.

		Returns:
		  - corresponding value asserted as int.
	*/
	GetInt(index int) int

	/*
		GetFloat acquires a float at the specified position in the list.
		Causes a panic if the element has another type.

		Parameters:
		  - index - position of the element to get.

		Returns:
		  - corresponding value asserted as float64.
	*/
	GetFloat(index int) float64

	/*
		TypeOf gives a type of the element at the specified position in the list.
		If the index is out of range, 0 (TypeUndefined) is returned.

		Parameters:
		  - index - position of the element.

		Returns:
		  - integer constant representing the type (see type enum).
	*/
	TypeOf(index int) Type

	/*
		String gives a JSON representation of the list, including nested lists and objects.

		Returns:
		  - JSON string.
	*/
	String() string

	/*
		FormatString gives a JSON representation of the list in standardized format with the given indentation.

		Parameters:
		  - indent - indentation spaces (0-10).

		Returns:
		  - JSON string.
	*/
	FormatString(indent int) string

	/*
		Slice converts the list into a Go slice of any.

		Returns:
		  - slice.
	*/
	Slice() []any

	/*
		NativeSlice converts the list into a Go slice of any.
		All nested objects and lists are converted recursively.

		Returns:
		  - slice.
	*/
	NativeSlice() []any

	/*
		ObjectSlice converts the list of objects into a Go slice.
		Elements of other types are ignored.

		Returns:
		  - slice.
	*/
	ObjectSlice() []Object

	/*
		ListSlice converts the list of lists into a Go slice.
		Elements of other types are ignored.

		Returns:
		  - slice.
	*/
	ListSlice() []List

	/*
		StringSlice converts the list of strings into a Go slice.
		Elements of other types are ignored.

		Returns:
		  - slice.
	*/
	StringSlice() []string

	/*
		BoolSlice converts the list of bools into a Go slice.
		Elements of other types are ignored.

		Returns:
		  - slice.
	*/
	BoolSlice() []bool

	/*
		IntSlice converts the list of ints into a Go slice.
		Elements of other types are ignored.

		Returns:
		  - slice.
	*/
	IntSlice() []int

	/*
		FloatSlice converts the list of floats into a Go slice.
		Elements of other types are ignored.

		Returns:
		  - slice.
	*/
	FloatSlice() []float64

	/*
		Clone creates a deep copy of the list.

		Returns:
		  - copied list.
	*/
	Clone() List

	/*
		Count gives a number of elements in the list.

		Returns:
		  - number of elements.
	*/
	Count() int

	/*
		Empty checks whether the list is empty.

		Returns:
		  - true if the list is empty, false otherwise.
	*/
	Empty() bool

	/*
		Equals checks if the content of the list is equal to the content of another list.
		Nested objects and lists are compared recursively (by value).

		Parameters:
		  - another - a list to compare with.

		Returns:
		  - true if the lists are equal, false otherwise.
	*/
	Equals(another List) bool

	/*
		Concat creates a new list containing all elements of the old list and another list.
		The old list remains unchanged.

		Parameters:
		  - another - a list to concat.

		Returns:
		  - new list.
	*/
	Concat(another List) List

	/*
		SubList creates a new list containing the elements from the starting index (including) to the ending index (excluding).
		If the ending index is zero, it is set to the length of the list. If negative, it is counted from the end of the list.
		Starting index has to be non-negative and cannot be higher than the ending index.

		Parameters:
		  - start - starting index,
		  - end - ending index.

		Returns:
		  - created sub list.
	*/
	SubList(start int, end int) List

	/*
		Contains checks if the list contains a given element.
		Objects and lists are compared by reference.

		Parameters:
		  - elem - the element to check.

		Returns:
		  - true if the list contains the element, false otherwise.
	*/
	Contains(elem any) bool

	/*
		IndexOf gives a position of the first occurrence of a given element.

		Parameters:
		  - elem - the element to check.

		Returns:
		  - index of the element (-1 if the list does not contain the element).
	*/
	IndexOf(elem any) int

	/*
		Sort sorts elements in the list (ascending).
		The first element of the list determines the sorting type and has to be either string, int or float.
		Values of other types are ignored.

		Returns:
		  - updated list.
	*/
	Sort() List

	/*
		Reverse reverses the order of elements in the list.

		Returns:
		  - updated list.
	*/
	Reverse() List

	/*
		AllObjects checks if the list is homogeneous and all of its elements are objects.

		Returns:
		  - true if all elements are objects, false otherwise.
	*/
	AllObjects() bool

	/*
		AllLists checks if the list is homogeneous and all of its elements are lists.

		Returns:
		  - true if all elements are lists, false otherwise.
	*/
	AllLists() bool

	/*
		AllStrings checks if the list is homogeneous and all of its elements are strings.

		Returns:
		  - true if all elements are strings, false otherwise.
	*/
	AllStrings() bool

	/*
		AllBools checks if the list is homogeneous and all of its elements are bools.

		Returns:
		  - true if all elements are bools, false otherwise.
	*/
	AllBools() bool

	/*
		AllInts checks if the list is homogeneous and all of its elements are ints.

		Returns:
		  - true if all elements are ints, false otherwise.
	*/
	AllInts() bool

	/*
		AllFloats checks if the list is homogeneous and all of its elements are floats.

		Returns:
		  - true if all elements are floats, false otherwise.
	*/
	AllFloats() bool

	/*
		AllNumeric checks if all elements of the list are numeric (ints or floats).

		Returns:
		  - true if all elements are numeric, false otherwise.
	*/
	AllNumeric() bool

	/*
		ForEach executes a given function over an every element of the list.
		The function has two parameters: index of the current element and its value.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEach(function func(i int, val any)) List

	/*
		ForEachValue executes a given function over an every element of the list.
		The function has one parameter, value of the current element.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEachValue(function func(x any)) List

	/*
		ForEachObject executes a given function over all objects in the list.
		Elements with other types are ignored.
		The function has one parameter, the current object.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEachObject(function func(x Object)) List

	/*
		ForEachList executes a given function over all lists nested in the list.
		Elements with other types are ignored.
		The function has one parameter, the current list.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEachList(function func(x List)) List

	/*
		ForEachString executes a given function over all strings in the list.
		Elements with other types are ignored.
		The function has one parameter, the current string.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEachString(function func(x string)) List

	/*
		ForEachBool executes a given function over all bools in the list.
		Elements with other types are ignored.
		The function has one parameter, the current bool.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEachBool(function func(x bool)) List

	/*
		ForEachInt executes a given function over all ints in the list.
		Elements with other types are ignored.
		The function has one parameter, the current int.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEachInt(function func(x int)) List

	/*
		ForEachFloat executes a given function over all floats in the list.
		Elements with other types are ignored.
		The function has one parameter, the current float.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEachFloat(function func(x float64)) List

	/*
		Map copies the list and modifies each element by a given mapping function.
		The resulting element can have a different type than the original one.
		The function has two parameters: current index and value of the current element. Returns any.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	Map(function func(i int, val any) any) List

	/*
		MapValues copies the list and modifies each element by a given mapping function.
		The resulting element can have a different type than the original one.
		The function has one parameter, value of the current element, and returns any.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	MapValues(function func(x any) any) List

	/*
		MapObjects selects all objects from the list and modifies each of them by a given mapping function.
		Elements of other types are ignored.
		The resulting element can have a different type than the original one.
		The function has one parameter, the current object, and returns any.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	MapObjects(function func(x Object) any) List

	/*
		MapLists selects all nested lists from the list and modifies each of them by a given mapping function.
		Elements of other types are ignored.
		The resulting element can have a different type than the original one.
		The function has one parameter, the current list, and returns any.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	MapLists(function func(x List) any) List

	/*
		MapStrings selects all strings from the list and modifies each of them by a given mapping function.
		Elements of other types are ignored.
		The resulting element can have a different type than the original one.
		The function has one parameter, the current string, and returns any.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	MapStrings(function func(x string) any) List

	/*
		MapBools selects all bools from the list and modifies each of them by a given mapping function.
		Elements of other types are ignored.
		The resulting element can have a different type than the original one.
		The function has one parameter, the current bool, and returns any.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	MapBools(function func(x bool) any) List

	/*
		MapInts selects all ints from the list and modifies each of them by a given mapping function.
		Elements of other types are ignored.
		The resulting element can have a different type than the original one.
		The function has one parameter, the current int, and returns any.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	MapInts(function func(x int) any) List

	/*
		MapFloats selects all floats from the list and modifies each of them by a given mapping function.
		Elements of other types are ignored.
		The resulting element can have a different type than the original one.
		The function has one parameter, the current float, and returns any.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	MapFloats(function func(x float64) any) List

	/*
		Reduce reduces all elements of the list into a single value.
		The function has two parameters: value returned by the previous iteration and value of the current element. Returns any.
		The list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - computed value.
	*/
	Reduce(initial any, function func(acc any, val any) any) any

	/*
		ReduceStrings reduces all strings in the list into a single string.
		Elements of other types are ignored.
		The function has two parameters: string returned by the previous iteration and current string. Returns string.
		The list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - computed value.
	*/
	ReduceStrings(initial string, function func(acc string, val string) string) string

	/*
		ReduceInts reduces all ints in the list into a single int.
		Elements of other types are ignored.
		The function has two parameters: int returned by the previous iteration and current int. Returns int.
		The list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - computed value.
	*/
	ReduceInts(initial int, function func(acc int, val int) int) int

	/*
		ReduceFloats reduces all floats in the list into a single float.
		Elements of other types are ignored.
		The function has two parameters: float returned by the previous iteration and current float. Returns float.
		The list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - computed value.
	*/
	ReduceFloats(initial float64, function func(acc float64, val float64) float64) float64

	/*
		Filter creates a new list containing elements of the old one satisfying a condition.
		The function has one parameter, value of the current element, and returns bool.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - filtered list.
	*/
	Filter(function func(x any) bool) List

	/*
		FilterObjects creates a new list containing objects of the old one satisfying a condition.
		Elements of other types are ignored.
		The function has one parameter, current object, and returns bool.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - filtered list.
	*/
	FilterObjects(function func(x Object) bool) List

	/*
		FilterLists creates a new list containing nested lists of the old one satisfying a condition.
		Elements of other types are ignored.
		The function has one parameter, current list, and returns bool.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - filtered list.
	*/
	FilterLists(function func(x List) bool) List

	/*
		FilterStrings creates a new list containing strings of the old one satisfying a condition.
		Elements of other types are ignored.
		The function has one parameter, current string, and returns bool.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - filtered list.
	*/
	FilterStrings(function func(x string) bool) List

	/*
		FilterInts creates a new list containing ints of the old one satisfying a condition.
		Elements of other types are ignored.
		The function has one parameter, current int, and returns bool.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - filtered list.
	*/
	FilterInts(function func(x int) bool) List

	/*
		FilterFloats creates a new list containing floats of the old one satisfying a condition.
		Elements of other types are ignored.
		The function has one parameter, current float, and returns bool.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - filtered list.
	*/
	FilterFloats(function func(x float64) bool) List

	/*
		IntSum computes a sum of all elements in the list.
		All elements of the list have to be ints.

		Returns:
		  - computed sum (int).
	*/
	IntSum() int

	/*
		Sum computes a sum of all elements in the list.
		All elements of the list have to be numeric.

		Returns:
		  - computed sum (float).
	*/
	Sum() float64

	/*
		IntProd computes a product of all elements in the list.
		All elements of the list have to be ints.

		Returns:
		  - computed product (int).
	*/
	IntProd() int

	/*
		Prod computes a product of all elements in the list.
		All elements of the list have to be numeric.

		Returns:
		  - computed pruduct (float).
	*/
	Prod() float64

	/*
		Avg computes an arithmetic mean of all elements in the list.
		All elements of the list have to be numeric.

		Returns:
		  - computed average value (float).
	*/
	Avg() float64

	/*
		IntMin finds a minimum int of the list.

		Returns:
		  - found minimum (int).
	*/
	IntMin() int

	/*
		Min finds a minimum number of the list.

		Returns:
		  - found minimum (float).
	*/
	Min() float64

	/*
		IntMax finds a maximum int of the list.

		Returns:
		  - found maximum (int).
	*/
	IntMax() int

	/*
		Max finds a maximum number of the list.

		Returns:
		  - found maximum (float).
	*/
	Max() float64

	/*
		ForEachAsync parallelly executes a given function over an every element of the list.
		The function has two parameters: index of the current element and its value.
		The order of the iterations is random.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged list.
	*/
	ForEachAsync(function func(i int, val any)) List

	/*
		MapAsync copies the list and paralelly modifies each element by a given mapping function.
		The resulting element can have a different type than the original one.
		The function has two parameters: index of the current element and its value.
		The old list remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	MapAsync(function func(i int, val any) any) List

	/*
		GetTF acquires a value specified by a given tree form.

		Parameters:
		  - tf - tree form string.

		Returns:
		  - corresponding value (any type, has to be asserted).
	*/
	GetTF(tf string) any

	/*
		SetTF sets a value specified by a given tree form.
		If the index exceeds the count, the interspace will be filled with nils.

		Parameters:
		  - tf - tree form string,
		  - value - value to set.

		Returns:
		  - updated list.
	*/
	SetTF(tf string, value any) List

	/*
		Unset deletes the value specified by a given tree form.
		If the TF path does not exist, nothing happens.

		Parameters:
		  - tf - tree form string.

		Returns:
		  - updated object.
	*/
	UnsetTF(tf string) List

	/*
		TypeOfTF gives a type of the element specified by a given tree form.
		If the TF path does not exist, 0 (TypeUndefined) is returned.

		Parameters:
		  - tf - tree form string.

		Returns:
		  - integer constant representing the type (see type enum).
	*/
	TypeOfTF(tf string) Type
	// contains filtered or unexported methods
}

List is an ordered sequence of elements.

func NewList

func NewList(values ...any) List

NewList creates a new list.

Parameters:

  • values... - any amount of initial elements.

Returns:

  • pointer to the created list.

func NewListFrom

func NewListFrom(slice any) List

NewListFrom converts a slice of supported types to a list.

Parameters:

  • slice - original slice.

Returns:

  • created list.

func NewListOf

func NewListOf(value any, count int) List

NewListOf creates a new list of n repeated values.

Parameters:

  • value - value to repeat,
  • count - number of repetitions.

Returns:

  • pointer to the created list.

func ParseList

func ParseList(json string) (List, error)

ParseList creates a new list from JSON. Patameters:

  • json - JSON string to parse.

Returns:

  • created list,
  • error if any occurred.

type Object

type Object interface {

	/*
		Init initializes the ego pointer, which allows deriving.

		Parameters:
		  - ptr - ego pointer.
	*/
	Init(ptr Object)

	/*
		Ego acquires the ego pointer previously set by Init.

		Returns:
		  - ego pointer.
	*/
	Ego() Object

	/*
		Set sets values of the fields.
		If the key already exists, the value is overwritten, if not, new field is created.
		If one key is given multiple times, the value is set to the last provided value.

		Parameters:
		  - values... - any amount of key-value pairs to set.

		Returns:
		  - updated object.
	*/
	Set(values ...any) Object

	/*
		Unset deletes the fields with the given keys. If the key does not exist, nothing happens.

		Parameters:
		  - keys... - any amount of keys to delete.

		Returns:
		  - updated object.
	*/
	Unset(keys ...string) Object

	/*
		Clear deletes all fields in the object.

		Returns:
		  - updated object.
	*/
	Clear() Object

	/*
		Get acquires a value under the specified key of the object.

		Parameters:
		  - key - key of the field to get.

		Returns:
		  - corresponding value (any type, has to be asserted).
	*/
	Get(key string) any

	/*
		GetObject acquires a nested object under the specified key of the object.
		Causes a panic if the field has another type.

		Parameters:
		  - key - key of the field to get.

		Returns:
		  - corresponding value asserted as object.
	*/
	GetObject(key string) Object

	/*
		GetList acquires a list under the specified key of the object.
		Causes a panic if the field has another type.

		Parameters:
		  - key - key of the field to get.

		Returns:
		  - corresponding value asserted as list.
	*/
	GetList(key string) List

	/*
		GetString acquires a string under the specified key of the object.
		Causes a panic if the field has another type.

		Parameters:
		  - key - key of the field to get.

		Returns:
		  - corresponding value asserted as string.
	*/
	GetString(key string) string

	/*
		GetBool acquires a bool under the specified key of the object.
		Causes a panic if the field has another type.

		Parameters:
		  - key - key of the field to get.

		Returns:
		  - corresponding value asserted as bool.
	*/
	GetBool(key string) bool

	/*
		GetInt acquires an int under the specified key of the object.
		Causes a panic if the field has another type.

		Parameters:
		  - key - key of the field to get.

		Returns:
		  - corresponding value asserted as int.
	*/
	GetInt(key string) int

	/*
		GetFloat acquires a float under the specified key of the object.
		Causes a panic if the field has another type.

		Parameters:
		  - key - key of the field to get.

		Returns:
		  - corresponding value asserted as float.
	*/
	GetFloat(key string) float64

	/*
		TypeOf gives a type of the field under the specified key of the object.
		If the key does not exist, 0 (TypeUndefined) is returned.

		Parameters:
		  - key - key of the field.

		Returns:
		  - integer constant representing the type (see type enum).
	*/
	TypeOf(key string) Type

	/*
		String gives a JSON representation of the object, including nested objects and lists.

		Returns:
		  - JSON string.
	*/
	String() string

	/*
		FormatString gives a JSON representation of the object in standardized format with the given indentation.

		Parameters:
		  - indent - indentation spaces (0-10).

		Returns:
		  - JSON string.
	*/
	FormatString(indent int) string

	/*
		Dict converts the object into a Go map of empty interfaces.

		Returns:
		  - map.
	*/
	Dict() map[string]any

	/*
		NativeDict converts the object into a Go map of empty interfaces.
		All nested objects and lists are converted recursively.

		Returns:
		  - map.
	*/
	NativeDict() map[string]any

	/*
		Keys convers the object to a list of its keys.

		Returns:
		  - list of keys of the object.
	*/
	Keys() List

	/*
		Values convers the object to a list of its values.

		Returns:
		  - list of values of the object.
	*/
	Values() List

	/*
		Clone creates a deep copy of the object.

		Returns:
		  - copied object.
	*/
	Clone() Object

	/*
		Count gives a number of fields of the object.

		Returns:
		  - number of fields.
	*/
	Count() int

	/*
		Empty checks whether the object is empty.

		Returns:
		  - true if the object is empty, false otherwise.
	*/
	Empty() bool

	/*
		Equals checks if the content of the object is equal to the content of another object.
		Nested objects and lists are compared recursively (by value).

		Parameters:
		  - another - an object to compare with.

		Returns:
		  - true if the objects are equal, false otherwise.
	*/
	Equals(another Object) bool

	/*
		Merge creates a new object containing all elements of the old object and another object.
		The old object remains unchanged.
		If both objects contain the same key, the value from another object is used.

		Parameters:
		  - another - an object to merge.

		Returns:
		  - new object.
	*/
	Merge(another Object) Object

	/*
		Pluck creates a new object containing the given fields of the existing object.
		The old object remains unchanged.

		Parameters:
		  - keys... - any amount of keys to be in the new object.

		Returns:
		  - new object.
	*/
	Pluck(keys ...string) Object

	/*
		Contains checks if the object contains a field with a given value.
		Objects and lists are compared by reference.

		Parameters:
		  - value - the value to check.

		Returns:
		  - true if the object contains the value, false otherwise.
	*/
	Contains(value any) bool

	/*
		KeyOf gives a key containing a given value.
		If multiple keys contain the value, any of them is returned.

		Parameters:
		  - value - the value to check.

		Returns:
		  - key for the value (empty string if the object does not contain the value).
	*/
	KeyOf(value any) string

	/*
		KeyExists checks if a given key exists within the object.

		Parameters:
		  - key - the key to check.

		Returns:
		  - true if the key exists, false otherwise.
	*/
	KeyExists(key string) bool

	/*
		ForEach executes a given function over an every field of the object.
		The function has two parameters: key of the current field and its value.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEach(function func(key string, val any)) Object

	/*
		ForEachValue executes a given function over an every field of the object.
		The function has one parameter, value of the current field.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEachValue(function func(x any)) Object

	/*
		ForEachObject executes a given function over all objects nested in the object.
		Fields of other types are ignored.
		The function has one parameter, the current object.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEachObject(function func(x Object)) Object

	/*
		ForEachList executes a given function over all lists in the object.
		Fields of other types are ignored.
		The function has one parameter, the current list.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEachList(function func(x List)) Object

	/*
		ForEachString executes a given function over all strings in the object.
		Fields of other types are ignored.
		The function has one parameter, the current string.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEachString(function func(x string)) Object

	/*
		ForEachBool executes a given function over all bools in the object.
		Fields of other types are ignored.
		The function has one parameter, the current bool.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEachBool(function func(x bool)) Object

	/*
		ForEachInt executes a given function over all ints in the object.
		Fields of other types are ignored.
		The function has one parameter, the current int.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEachInt(function func(x int)) Object

	/*
		ForEachFloat executes a given function over all floats in the object.
		Fields of other types are ignored.
		The function has one parameter, the current float.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEachFloat(function func(x float64)) Object

	/*
		Map copies the object and modifies each field by a given mapping function.
		The resulting field can have a different type than the original one.
		The function has two parameters: current key and value of the current element. Returns any.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new list.
	*/
	Map(function func(key string, val any) any) Object

	/*
		MapValues copies the object and modifies each field by a given mapping function.
		The resulting field can have a different type than the original one.
		The function has one parameter, value of the current field, and returns any.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new object.
	*/
	MapValues(function func(x any) any) Object

	/*
		MapObjects selects all nested objects in the object and modifies each of them by a given mapping function.
		Fields with other types are ignored.
		The resulting field can have a different type than the original one.
		The function has one parameter, the current object, and returns any.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new object.
	*/
	MapObjects(function func(x Object) any) Object

	/*
		MapLists selects all lists in the object and modifies each of them by a given mapping function.
		Fields with other types are ignored.
		The resulting field can have a different type than the original one.
		The function has one parameter, the current list, and returns any.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new object.
	*/
	MapLists(function func(x List) any) Object

	/*
		MapStrings selects all strings in the object and modifies each of them by a given mapping function.
		Fields with other types are ignored.
		The resulting field can have a different type than the original one.
		The function has one parameter, the current string, and returns empty interface.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new object.
	*/
	MapStrings(function func(x string) any) Object

	/*
		MapBools selects all bools in the object and modifies each of them by a given mapping function.
		Fields with other types are ignored.
		The resulting field can have a different type than the original one.
		The function has one parameter, the current bool, and returns empty interface.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new object.
	*/
	MapBools(function func(x bool) any) Object

	/*
		MapInts selects all ints in the object and modifies each of them by a given mapping function.
		Fields with other types are ignored.
		The resulting field can have a different type than the original one.
		The function has one parameter, the current int, and returns empty interface.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new object.
	*/
	MapInts(function func(x int) any) Object

	/*
		MapFloats selects all floats in the object and modifies each of them by a given mapping function.
		Fields with other types are ignored.
		The resulting field can have a different type than the original one.
		The function has one parameter, the current float, and returns empty interface.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new object.
	*/
	MapFloats(function func(x float64) any) Object

	/*
		ForEachAsync parallelly executes a given function over an every field of the object.
		The function has two parameters: key of the current field and its value.
		The order of the iterations is random.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - unchanged object.
	*/
	ForEachAsync(function func(key string, val any)) Object

	/*
		MapAsync copies the object and paralelly modifies each field by a given mapping function.
		The resulting field can have a different type than the original one.
		The function has two parameters: key of the current field and its value.
		The old object remains unchanged.

		Parameters:
		  - function - anonymous function to be executed.

		Returns:
		  - new object.
	*/
	MapAsync(function func(key string, val any) any) Object

	/*
		GetTF acquires a value specified by a given tree form.

		Parameters:
		  - tf - tree form string.

		Returns:
		  - corresponding value (any type, has to be asserted).
	*/
	GetTF(tf string) any

	/*
		SetTF sets a value specified by a given tree form.

		Parameters:
		  - tf - tree form string,
		  - value - value to set.

		Returns:
		  - updated object.
	*/
	SetTF(tf string, value any) Object

	/*
		Unset deletes the value specified by a given tree form.
		If the TF path does not exist, nothing happens.

		Parameters:
		  - tf - tree form string.

		Returns:
		  - updated object.
	*/
	UnsetTF(tf string) Object

	/*
		TypeOfTF gives a type of the field specified by a given tree form.
		If the TF path does not exist, 0 (TypeUndefined) is returned.

		Parameters:
		  - tf - tree form string.

		Returns:
		  - integer constant representing the type (see type enum).
	*/
	TypeOfTF(tf string) Type
	// contains filtered or unexported methods
}

Object is an unordered set of key-value pairs.

func NewObject

func NewObject(values ...any) Object

NewObject creates a new object.

Parameters:

  • values... - any amount of key-value pairs to set after the object creation.

Returns:

  • pointer to the created object.

func NewObjectFrom

func NewObjectFrom(dict any) Object

NewObjectFrom converts a map of supported types to an object.

Parameters:

  • dict - original map.

Returns:

  • created object.

func ParseFile

func ParseFile(path string) (Object, error)

ParseFile creates a new object from JSON file. Patameters:

  • path - path to the file to parse.

Returns:

  • created object,
  • error if any occurred.

func ParseObject

func ParseObject(json string) (Object, error)

ParseObject creates a new object from JSON. Patameters:

  • json - JSON string to parse.

Returns:

  • created object,
  • error if any occurred.

type Type

type Type uint8

Type is an enum of AnyType data types.

const (
	TypeUndefined Type = iota
	TypeNil
	TypeObject
	TypeList
	TypeString
	TypeBool
	TypeInt
	TypeFloat
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL