In this short article, I show you how to shuffle your array. In other words, we will randomly reorder the elements in the array. So let’s get started. Sample case I have an array of numbers like Anytime I run the operation I would like to receive different order of elements in the array. Here…
Discover how to sign AWS API Request using DataWeave
MuleSoft and its Partners are publishing many connectors. It’s great as we can quickly and with less overhead start integrating with 3rd parties. However, there are situations where no connector exists. This may happen for smaller or bigger systems. I come across that challenge while trying to call AWS service through its REST API. This…
How to get months and years difference between the two dates?
Some time ago, I was asked to compute the difference between the two dates (Period). Sounds simple, isn’t it? However, I needed this difference presented in days, months, and years. It was not that obvious how to achieve that. Let’ see how I did it. Overview We want to see how long given employee is…
Content Filter pattern for REST service – implementation
In the last article, you can find the idea of how to introduce field filtering for your APIs. My simplified Content Filter allows for providing negative or positive filtering. The first one tells which fields Filter removes from the target response. The latter one tells which fields should be available in the response. Today I…
Content Filter pattern for REST service fields filtering
At some point, you may have a service that returns a lot of fields and related objects. What if the service consumer doesn’t want all the fields all the time? In other words, he/she would like to have the response filtered. Here come the Content Filter to the rescue. After you read this article you…
DataWeave Tip #8 – write function
Recently I have been working on a really simple case. When an HTTP server returned an error and not empty body I needed to embed this body into an error structure. Although this is simple case I got a problem with implementing it in Mule 4. In the previous Mule edition it was a little bit simpler. So let’s see what it is all about.
DataWeave Modules, new way to introduce reusability
It is always desirable to reuse as much code as possible. We can do the same regarding DataWeave transformations and custom functions. In this article, I will describe how to reuse code in the newest DataWeave using modules. For those working with DataWeave 1.0, I will describe how to reuse code with readUrl function. DataWeave…
Remove empty JSON objects from payload using DataWeave function
During transformation to JSON, we often do not want null properties. It is easy to remove them, by just using the skipNullOn attribute. However, for empty objects, it is not that trivial, especially when you have to deal with many such cases within one transformation. In this article, I will show you how you can…
Huge number in exponential notation in DataWeave. How to convert it?
In the last article, I have described a nuisance with casting to an integer value. This time we will look at huge numbers and their formatting. In addition, I will mention scientific notation. All these topics are around the number format used by the DataWeave engine. So let’s see what the problem looks like. Problem…
Using filter selector in DataWeave to easily extract data from array
There are times when you need to get one particular element from an array, but not based on the index. This item needs to fulfill some requirements like equality and so on. In order to perform that task filter selector ‘?‘ was introduced. This is applicable for both DataWeave 1 and 2. Filter selector syntax…