This extension provides the capability to send a map object inside Siddhi stream definitions and use it inside queries. The following are the functions of the map
extension.
Create Function
Syntax |
or
|
---|---|
Extension Type | Function |
Description | Returns the created map object. |
Examples |
|
Get Function
Syntax | <Object> map:get(<Map> map, <Object> key) |
---|---|
Extension Type | Function |
Description | Returns the value object from the map that is related to the given key. |
Example | get(company,1) returns the value that is related to the key 1 from the map named company . |
Is Map Function
Syntax | <bool> map:isMap(<Object> object) |
---|---|
Extension Type | Function |
Description | Returns true if the object is a map or false otherwise. |
Example | isMap(students) returns true if the students object is a map. It returns false if the students object is not a map. |
Put Function
Syntax |
|
---|---|
Extension Type | Function |
Description | Returns the updated map after adding the given key-value pair. |
Example | put(students , 1234 , ”sam”) returns the updated map named students after adding the object "sam" with key 1234 . |
Remove Function
Syntax | <Object> map:remove(<Object> map, <Object> key) |
---|---|
Extension Type | Function |
Description | Returns the updated map after removing the element with key. |
Example | remove(students , 1234) returns the updated map students after removing the element with the key 1234 . |
Create From JSON Function
Syntax | <Object> map:createFromJSON(<string> JSONstring) |
---|---|
Extension Type | Function |
Description | Returns the map created with the key values pairs given in the JSONstring . |
Example | 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. |
Create From XML Function
Syntax | <Object> map:createFromXML(<string> XMLstring) |
---|---|
Extension Type | Function |
Description | Returns the map created with the key values pairs given in the XMLstring. |
Example | createFromXML(“<company> <symbol> wso2 </symbol> <price> <100> </price> <volume> 200 </volume> </company>”) returns a map with the keys "symbol" , "price" , "volume" , and with the values WSO2 , 100 and 200 respectively. |
To JSON Function
Syntax | <String> map:toJSON(<Object> map) |
---|---|
Extension Type | Function |
Description | Converts a map into a JSON object and returns the definition of that JSON object as a string. |
Example | If "company" is a map with key value pairs ("symbol" : wso2) , ("volume" : 100) , and ("price",200) , toJSON(company) returns the string “{“symbol” : “wso2” , “volume” : 100 , “price” : 200}” . |
To XML Function
Syntax |
or
|
---|---|
Extension Type | Function |
Description | Returns the map as an XML string. |
Example | If
|