Documentation ¶
Index ¶
- Constants
- func ExtractPath(expression string) string
- func Parse(expression string, ...) interface{}
- type Collection
- func (s *Collection) PadWithMap(size int)
- func (s *Collection) Push(value interface{})
- func (s *Collection) Range(handler func(item interface{}, index int) (bool, error)) error
- func (s *Collection) RangeInt(handler func(item interface{}, index int) (bool, error)) error
- func (s *Collection) RangeMap(handler func(item Map, index int) (bool, error)) error
- func (s *Collection) RangeString(handler func(item interface{}, index int) (bool, error)) error
- func (s *Collection) String() string
- type CompactedSlice
- func (s *CompactedSlice) Add(data map[string]interface{})
- func (s *CompactedSlice) Fields() []*Field
- func (s *CompactedSlice) Iterator() toolbox.Iterator
- func (d CompactedSlice) MarshalJSON() ([]byte, error)
- func (s *CompactedSlice) Range(handler func(item interface{}) (bool, error)) error
- func (s *CompactedSlice) Ranger() toolbox.Ranger
- func (s *CompactedSlice) Size() int
- func (s *CompactedSlice) SortedIterator(indexBy []string) (toolbox.Iterator, error)
- func (s *CompactedSlice) SortedRange(indexBy []string, handler func(item interface{}) (bool, error)) error
- type Field
- type Map
- func (s *Map) Apply(source map[string]interface{})
- func (s *Map) AsEncodableMap() map[string]interface{}
- func (s *Map) Clone() Map
- func (s *Map) Delete(keys ...string)
- func (s *Map) Expand(source interface{}) interface{}
- func (s *Map) ExpandAsText(text string) string
- func (s *Map) ExpandWithoutUDF(text string) string
- func (s *Map) Get(key string) interface{}
- func (s *Map) GetBoolean(key string) bool
- func (s *Map) GetCollection(key string) *Collection
- func (s *Map) GetFloat(key string) float64
- func (s *Map) GetInt(key string) int
- func (s *Map) GetMap(key string) Map
- func (s *Map) GetString(key string) string
- func (s *Map) GetValue(expr string) (interface{}, bool)
- func (s *Map) Has(key string) bool
- func (s *Map) Put(key string, value interface{})
- func (s *Map) Range(callback func(k string, v interface{}) (bool, error)) error
- func (s *Map) Replace(key, val string)
- func (s *Map) SetValue(expr string, value interface{})
- type Udf
Constants ¶
const (
UDFKey = "_udf"
)
Variables ¶
This section is empty.
Functions ¶
func ExtractPath ¶
Types ¶
type Collection ¶
type Collection []interface{}
Collection represents a slice of interface{} (generic type)
func NewCollection ¶
func NewCollection() *Collection
NewCollection creates a new collection and returns a pointer
func (*Collection) PadWithMap ¶
func (s *Collection) PadWithMap(size int)
PadWithMap creates missing elements with a map
func (*Collection) Push ¶
func (s *Collection) Push(value interface{})
Push appends provided value to the slice
func (*Collection) Range ¶
func (s *Collection) Range(handler func(item interface{}, index int) (bool, error)) error
Range iterates over every item in this collection as long as handler returns true. Handler takes an index and index of the slice element.
func (*Collection) RangeInt ¶
func (s *Collection) RangeInt(handler func(item interface{}, index int) (bool, error)) error
RangeMap iterates every int item in this collection as long as handler returns true. Handler takes an index and index of the slice element
func (*Collection) RangeMap ¶
RangeMap iterates every map item in this collection as long as handler returns true. Handler takes an index and index of the slice element
func (*Collection) RangeString ¶
func (s *Collection) RangeString(handler func(item interface{}, index int) (bool, error)) error
RangeMap iterates every string item in this collection as long as handler returns true. Handler takes an index and index of the slice element
func (*Collection) String ¶
func (s *Collection) String() string
String returns a string representation of this collection
type CompactedSlice ¶
type CompactedSlice struct { RawEncoding bool // contains filtered or unexported fields }
CompactedSlice represented a compacted slice to represent object collection
func NewCompactedSlice ¶
func NewCompactedSlice(omitEmpty, compressNils bool) *CompactedSlice
NewCompactedSlice create new compacted slice
func (*CompactedSlice) Add ¶
func (s *CompactedSlice) Add(data map[string]interface{})
Add adds data to a collection
func (*CompactedSlice) Fields ¶ added in v0.18.0
func (s *CompactedSlice) Fields() []*Field
func (*CompactedSlice) Iterator ¶ added in v0.6.6
func (s *CompactedSlice) Iterator() toolbox.Iterator
Iterator returns a slice iterator
func (CompactedSlice) MarshalJSON ¶ added in v0.29.2
func (d CompactedSlice) MarshalJSON() ([]byte, error)
func (*CompactedSlice) Range ¶
func (s *CompactedSlice) Range(handler func(item interface{}) (bool, error)) error
Range iterate over slice, and remove processed data from the compacted slice
func (*CompactedSlice) Ranger ¶ added in v0.18.0
func (s *CompactedSlice) Ranger() toolbox.Ranger
Ranger moves data from slice to ranger
func (*CompactedSlice) SortedIterator ¶ added in v0.6.6
func (s *CompactedSlice) SortedIterator(indexBy []string) (toolbox.Iterator, error)
SortedIterator returns sorted iterator
func (*CompactedSlice) SortedRange ¶ added in v0.6.6
func (s *CompactedSlice) SortedRange(indexBy []string, handler func(item interface{}) (bool, error)) error
SortedRange sort collection by supplied index and then call for each item supplied handler callback
type Map ¶
type Map map[string]interface{}
Map types is an alias type to map[string]interface{} with extended behaviours
func (*Map) AsEncodableMap ¶
Returns a map that can be encoded by json or other decoders. Since a map can store a function, it filters out any non marshalable types.
func (*Map) Delete ¶
Delete removes the supplied keys, it supports key of path expression with dot i.e. request.method
func (*Map) Expand ¶
func (s *Map) Expand(source interface{}) interface{}
Expand expands provided value of any type with dollar sign expression/
func (*Map) ExpandAsText ¶
ExpandAsText expands all matching expressions starting with dollar sign ($)
func (*Map) ExpandWithoutUDF ¶ added in v0.35.0
ExpandWithoutUDF expands text like ExpandAsText but keeps quotes for function arguments
func (*Map) GetBoolean ¶
GetBoolean returns value for provided key as boolean.
func (*Map) GetCollection ¶
func (s *Map) GetCollection(key string) *Collection
GetCollection returns value for provided key as collection pointer.
func (*Map) GetValue ¶
GetValue returns value for provided expression. The expression uses dot (.) to denote nested data structure. The following expression as supported
- <-key shift
- ++key pre increment
- key++ post increment
- $key reference access
func (*Map) Range ¶
Range iterates every key, value pair of this map, calling supplied callback as long it does return true.
func (*Map) SetValue ¶
Set value sets value in the map for the supplied expression. The expression uses dot (.) to denote nested data structure. For instance the following expression key1.subKey1.attr1 Would take or create map for key1, followied bu takeing or creating antother map for subKey1 to set attr1 key with provided value The following expression as supported
- $key reference - the final key is determined from key's content.
- ->key push expression to append value at the end of the slice