Functions
divideBy
divideBy(Object, Number): Array<Object>
Divides the object into sub-objects with the specified number of properties.
Transform
1
2
3
4
%dw 2.0
import divideBy from dw::core::Objects
---
{a: 123,b: true, a:123, b:false} divideBy 2
Output
1
2
3
4
5
6
7
8
9
10
[
{
"a": 123,
"b": true
},
{
"a": 123,
"b": false
}
]
entrySet
entrySet(T)
Returns a list of key-value pair objects that describe the object entries.
Transform
1
2
3
4
%dw 2.0
import dw::core::Objects
---
Objects::entrySet({a: true, b: 1})
Output
1
2
3
4
5
6
7
8
9
10
11
12
[
{
key: "a",
value: true,
attributes: null
},
{
key: "b",
value: 1,
attributes: null
}
]
keySet
keySet(T): ?
Returns the list of key names from an object.
Transform
1
2
3
4
%dw 2.0
import dw::core::Objects
---
Objects::keySet({a: true, b: 1})
Output
1
["a","b"]
mergeWith
mergeWith(T, V): ?
Keeps the target object intact, then appends to the target object any key-value pairs from the source where the key is not already in the target.
Transform
1
2
3
4
%dw 2.0
import mergeWith from dw::core::Objects
---
{a: true, b: 1} mergeWith {a: false, c: "Test"}
Output
1
{"a": false, "b": 1 , "c": "Test"}
mergeWith(Null, T): T
Helper method to make mergeWith
null friendly.
mergeWith(T, Null): T
Helper method to make mergeWith
null friendly.
nameSet
nameSet(Object): Array<String>
Returns the list of key names from an object.
Transform
1
2
3
4
%dw 2.0
import dw::core::Objects
---
Objects::nameSet({a: true, b: 1})
Output
1
["a","b"]
valueSet
valueSet({ (K)?: V }): Array<V>
Returns the list of key values of an object.
Transform
1
2
3
4
%dw 2.0
import dw::core::Objects
---
Objects::valueSet({a: true, b: 1})
Output
1
[true,1]