DataWeave : filterObject()
filterObject (Object<Key,Value>, (Value,Key,index) -> Object): Object
Table of contents
filterObject () :
filterObject always works on Objects. It Iterates over key-value pairs in an object and applies a conditional expression that returns only matching key value pairs, filtering out the unmatched key value pairs.
The conditional expression must return true or false. If the expression returns true for a key, value, or index of an object, the object gets in the output.
If it returns false for any of them, the object gets filtered out of the output. If there are no matches, the output array will be empty.
Note : An Object starts with { and end with } and inside it has key-value pairs or nil
Note : Whenever we are applying filterObject function other than the Objects and null, we get the exception
filterObject (Object, (Value,Key,index) -> Object): Object
Value(default $): it represents the value part of a key-value pair in an object
Example :
In the below image we are applying filterObject
condition: filtering key-value pairs with values starts with "N" character
with default syntax :
Key(default $$) : it represents the key part of a key-value pair in an object
Example :
with default syntax :
Index(default $$$) : it represents the Index part of a key-value pair in an object
Example :
with default syntax :
When input is null:
filterObject gives null as output when input is null
Example:
Exception case:
Here we got an error while applying filterObject on an Array
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
#mulesoft #dataweave #dw #anypointstudio #mule #muleEsb #filterObject #filterObject ()