A string value can be seen as an array of characters and if we want to transform our string value to an array we can use the toArray
function in the dw::util::Coercions
module. Once we have transformed our string to an array we can use all functions that work on arrays. The nice thing about DataWeave is that some functions that work on arrays already have an overloaded version that accepts a string value. Then we don’t have to explicitly use the toArray
function, but we can simply use our original value when we invoke the function.
Continue reading →
When we create an object structure it is very useful to use dynamic elements. Dynamic elements can turn an object or array of objects into key and value pairs in an object constructor. The syntax of the dynamic element is that an object or array of objects is enclosed in parentheses ((…)
). We use this inside an object constructor enclosed in curly braces ({…}
) so we get the key/value pairs. The objects can be referenced by a variable or a function that returns an object.
Continue reading →
Sometimes we get a data structure with keys and values and we want to create an array with data from the data structure. DataWeave gives us the pluck
function to achieve this. The input argument is an object and a lambda and the output must be an array. We use a lambda to define the mapping from our object to elements in the resulting array. The lambda has three arguments: the value for a key, the key itself and the index of the key in the object. We have a handle on all data to pluck the information and transform it to elements in an array.
Continue reading →
When we create an object structure it is very useful to use dynamic elements. Dynamic elements can turn an object or array of objects into key and value pairs in an object constructor. The syntax of the dynamic element is that an object or array of objects is enclosed in parentheses ((…)
). We use this inside an object constructor enclosed in curly braces ({…}
) so we get the key/value pairs. The objects can be referenced by a variable or a function that returns an object.
Continue reading →
A string value can be seen as an array of characters and if we want to transform our string value to an array we can use the toArray
function in the dw::util::Coercions
module. Once we have transformed our string to an array we can use all functions that work on arrays. The nice thing about DataWeave is that some functions that work on arrays already have an overloaded version that accepts a string value. Then we don’t have to explicitly use the toArray
function, but we can simply use our original value when we invoke the function.
Continue reading →
You probably hear it a lot: you should make your code secure! But… how?
When it comes to security, there are a plethora of measures you can implement.
Where do you start, and how do you know you’re doing the right thing?
Continue reading →
We can turn a URL string value into an object with fields that contain information about the URL using the parseURI
function. This function is part of the code dw::core::URL
module. The returned object is of type URI
and has fields like host
, path
, query
, scheme
and more.
Continue reading →
In DataWeave we can use expressions in strings that will be evaluated and inserted into the string value. This is called string interpolation. The expression must be enclosed in parentheses where the first parenthesis is prefixed with a dollar sign: $(<expression>)
. The expression must return a string value or can be automatically coerced into a string value in order for it to work. The expression can also be a variable.
Continue reading →
In DataWeave we can calculate the average for an array of numbers with the avg
function. If we want to calculate the average for other types in an array or object if we first transform the source object to an array of numbers.
Continue reading →
To get a v4 UUID in DataWeave we must use the function uuid
from the dw::Core
module. The function simply returns a value that is created using random numbers. So each time we invoke the function we will get a different value.
Continue reading →