# README
Expandable Collection User Defined Function
Usage
Data substitution
aMap := data.NewMap();
aMap.Put("ts", "2015-02-11")
udf.Register(aMap)
expanded := aMap.ExpandAsText(`$FormatTime($ts, "yyyy")`)
Data node selection
holder := data.NewMap()
collection := data.NewCollection()
collection.Push(map[string]interface{}{
"amount": 2,
"id":2,
"name":"p1",
"vendor":"v1",
})
collection.Push(map[string]interface{}{
"amount": 12,
"id":3,
"name":"p2",
"vendor":"v2",
})
holder.SetValue("node1.obj", collection)
records, err := Select([]interface{}{"node1/obj/*", "id", "name:product"}, holder)
The list of defined UDFs
- Length, Len returns length of slice, map or string
- AsMap - convert source into a map, it accepts data structure, or JSON, YAML literal
- AsCollection - convert source into a slice, it accepts data structure, or JSON, YAML literal
- AsData - convert source into a map or slice, it accepts data structure, or JSON, YAML literal
- AsInt - convert source into a an int
- AsFloat - convert source into a a float
- AsBool - convert source into a boolean
- AsNumber - converts to either int or float
- FormatTime, takes two arguments, date or now, followed by java style date format
- Values - returns map values
- Keys - return map keys
- IndexOf - returns index of matched slice element
- Join - join slice element with supplied separator
- Split - split text by separator
- Sum - sums values for matched Path, i.e. $Sum('node1/obj/*/amount')
- Count - counts values for matched Path, i.e. $Sum('node1/obj/*/amount')
- Select - selects attribute for matched path, i.e $Select("node1/obj/*", "id", "name:product")
- QueryEscape - url escape
- QueryUnescape - url unescape
- Base64Encode
- Base64DecodeText
- TrimSpace
- Elapsed elapsed time
- Rand
- Replace
- ToLower
- ToUpper
- AsNewLineDelimitedJSON
# Functions
AsBool converts source into bool.
AsCollection converts source into a slice.
AsData converts source into map or slice.
AsFloat converts source into float64.
AsFloat32 converts source into float32.
AsFloat32 converts source into float32.
AsInt converts source into int.
AsJSON converts source to JSON.
AsMap converts source into map.
AsNewLineDelimitedJSON convers a slice into new line delimited JSON.
AsNumber return int or float.
AsInt converts source into int.
AsStringMap returns map[string]string.
Base64Decode decodes source using base64.StdEncoding.
Base64DecodeText decodes source using base64.StdEncoding to string.
Base64Decode encodes source using base64.StdEncoding.
Base64RawURLDecode decodes source using base64.RawURLEncoding.
Base64RawURLEncode encodes source using base64.RawURLEncoding.
Concat concatenate supplied parameters, parameters.
Count returns count of matched nodes leaf value.
Elapsed returns elapsed time.
FormatTime return formatted time, it takes an array of arguments, the first is time express, or now followed by java style time format, optional timezone and truncate format .
IndexOf returns index of the matched slice elements or -1.
Join joins slice by separator.
Keys returns keys of the supplied map.
Length returns length of slice or string.
LoadJSON loads new line delimited or regular JSON into data structure.
Merge creates a new merged map for supplied maps, (mapOrPath1, mapOrPath2, mapOrPathN).
QueryEscape returns url escaped text.
QueryUnescape returns url escaped text.
Rand returns random.
No description provided by the author
Replace replaces text with old and new fragments.
Select returns all matched attributes from matched nodes, attributes can be alised with sourcePath:alias.
Split split text to build a slice.
Keys returns keys of the supplied map.
Sum returns sums of matched nodes leaf value.
Lower converts string to lower case.
Lower converts string to upper case.
TrimSpace returns trims spaces from supplied text.
Type returns source type.
Values returns values of the supplied map.
# Variables
No description provided by the author