API Docs - v4.0.19
Map
create (Function)
This creates a map between the keys and their corresponding values.
Syntax
<OBJECT> map:create(<OBJECT> key1, <OBJECT> value1, <OBJECT> key2, <OBJECT> value2)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
key1 | key 1 | OBJECT | No | No | |
value1 | Value 1 | OBJECT | No | No | |
key2 | Key 2 | OBJECT | No | No | |
value2 | Value 2 | OBJECT | No | No |
Examples EXAMPLE 1
create(1 , ?one? , 2 , ?two? , 3 , ?three?)
This returns a map with keys 1, 2, 3 mapped with their corresponding values, "one", "two", "three".
createFromJSON (Function)
This returns the map created by pairing the keys with its corresponding values given in the JSON string.
Syntax
<OBJECT> map:createFromJSON(<STRING> json.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
json.string | JSON as a string, which is used to create the map. | STRING | No | No |
Examples EXAMPLE 1
createFromJSON(?{?symbol' : 'IBM' , 'price' : 200, 'volume' : 100}?)
This returns a map with the keys "symbol", "price", "volume", and its values, "IBM", 200 and 100 respectively.
createFromXML (Function)
This returns the map created by pairing the keys with their corresponding values,given as an XML string.
Syntax
<OBJECT> map:createFromXML(<STRING> xml.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
xml.string | The XML string, which is used to create the map. | STRING | No | No |
Examples EXAMPLE 1
createFromJSON(?{?symbol' : 'IBM' , 'price' : 200, 'volume' : 100}?)
returns a map with the keys "symbol", "price", "volume", and with the values "IBM", 200 and 100 respectively.
get (Function)
This returns the value object, that corresponds to the given key, from the map.
Syntax
<OBJECT> map:get(<OBJECT> map, <OBJECT> key)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
map | The map from where the value should be obtained | OBJECT | No | No | |
key | The key of the value which needs to be returned | OBJECT | No | No |
Examples EXAMPLE 1
get(company,1)
This function returns the value that is associated with the key, i.e., 1, from a map named company.
isMap (Function)
This returns 'true' if the object is a map and 'false' if otherwise.
Syntax
<BOOL> map:isMap(<OBJECT> object)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
object | The object that the function checks to determine whether it's a map or not. | OBJECT | No | No |
Examples EXAMPLE 1
isMap(students)
This function returns 'true' if the object, students is a map. It returns 'false' if it is not a map.
put (Function)
This returns the updated map after adding the given key-value pair.
Syntax
<OBJECT> map:put(<OBJECT> map, <OBJECT> key, <OBJECT> value)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
map | The map to which the value should be added. | OBJECT | No | No | |
key | The key of the value added. | OBJECT | No | No | |
value | The new value. | OBJECT | No | No |
Examples EXAMPLE 1
put(students , 1234 , ?sam?)
This function returns the updated map named students after adding the object "sam" with key 1234.
putAll (Function)
This returns the updated 'to.map' map after copying all of the mappings from the specified 'from.map.' map. If there are duplicate keys, 'from.map' overwrites the values into the 'to.map.' map.
Syntax
<OBJECT> map:putAll(<OBJECT> to.map, <OBJECT> from.map)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
to.map | The map into which the mappings need to copied. | OBJECT | No | No | |
from.map | The map from which the mappings are copied. | OBJECT | No | No |
Examples EXAMPLE 1
putAll(toMap , fromMap)
This returns the updated map named 'toMap' after adding each mapping from 'fromMap.'
remove (Function)
This returns the updated map after removing the element with the key specified.
Syntax
<OBJECT> map:remove(<OBJECT> map, <OBJECT> key)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
map | The map that needs to be updated by removing the element. | OBJECT | No | No | |
key | The key of the element that needs to removed from the map. | OBJECT | No | No |
Examples EXAMPLE 1
remove(students , 1234)
This function returns the updated map, students after removing the element with the key 1234.
toJSON (Function)
This converts a map into a JSON object and returns the definition of that JSON object as a string.
Syntax
<STRING> map:toJSON(<OBJECT> map)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
map | The map that needs to be converted to JSON | OBJECT | No | No |
Examples EXAMPLE 1
toJSON(company)
If "company" is a map with key-value pairs, ("symbol" : wso2),("volume" : 100), and ("price",200), it returns the string ?{?symbol? : ?wso2?, ?volume? : 100 , ?price? : 200}?.
toXML (Function)
This returns the map as an XML string.
Syntax
<STRING> map:toXML(<OBJECT> map, <OBJECT> rootelementname)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
map | The map that needs to be converted to XML. | OBJECT | No | No | |
rootelementname | The root element of the map. | null | OBJECT | Yes | No |
Examples EXAMPLE 1
toXML(company, "abcCompany")
If "company" is a map with key-value pairs, (?symbol? : wso2), (?volume? : 100), and (?price? : 200), this function returns the string, ?<abcCompany><symbol>wso2</symbol><volume><100></volume><price>200</price></abcCompany>.