API Docs - v4.0.5
Map
toJSON (Function)
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 | map that nedded 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). This will returns the string ?{?symbol? : ?wso2? , ?volume? : 100 , ?price? : 200}?.
get (Function)
Returns the value object from the map that is related to the given key.
Syntax
<OBJECT> map:get(<OBJECT> map, <OBJECT> key)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
map | Map where the value should return | OBJECT | No | No | |
key | Key of the value which needed to return | OBJECT | No | No |
Examples EXAMPLE 1
get(company,1)
returns the value that is related to the key 1 from the map named company.
create (Function)
Returns the created map object.
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?)
returns a map with keys 1, 2, 3 and corresponding values "one", "two", "three"
toXML (Function)
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 | map that needed to convert to XML | OBJECT | No | No | |
rootelementname | 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 will returns the string ?<abcCompany><symbol>wso2</symbol><volume><100></volume><price>200</price></abcCompany>
isMap (Function)
Returns true if the object is a map or false otherwise.t
Syntax
<BOOL> map:isMap(<OBJECT> object)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
object | Object that needs to be checked whether it is a map | OBJECT | No | No |
Examples EXAMPLE 1
isMap(students)
returns true if the students object is a map. It returns false if the students object is not a map.
put (Function)
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 | Map that value should add | OBJECT | No | No | |
key | Key of the value | OBJECT | No | No | |
value | New value | OBJECT | No | No |
Examples EXAMPLE 1
put(students , 1234 , ?sam?)
returns the updated map named students after adding the object "sam" with key 1234.
createFromXML (Function)
Returns the map created with the key values pairs given in the XMLstring.
Syntax
<OBJECT> map:createFromXML(<STRING> xml.string)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
xml.string | XML as a 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.
remove (Function)
Returns the updated map after removing the element with key.
Syntax
<OBJECT> map:remove(<OBJECT> map, <OBJECT> key)
QUERY PARAMETERS
Name | Description | Default Value | Possible Data Types | Optional | Dynamic |
---|---|---|---|---|---|
map | Map that needed to remove the element | OBJECT | No | No | |
key | key of the element the needed to remove | OBJECT | No | No |
Examples EXAMPLE 1
remove(students , 1234)
returns the updated map students after removing the element with the key 1234
createFromJSON (Function)
Returns the map created with the key values pairs given in the JSONstring.
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}?)
returns a map with the keys "symbol", "price", "volume", and with the values "IBM", 200 and 100 respectively.