Did you already know that Alumio supports the JMESPath query language? This enables you to manipulate your data even easier than before, as this allows you to execute code-like methods directly on your data.
Let me provide you with two examples!
Sorting lists
Let’s assume we have the following data:
{
"unsorted_list": [10,6,8,12]
}
Text
In order to sort this list, we can use the *sort function (*documentation: JMESPath Specification — JMESPath) to let JMESPath automatically sort this for us. The sample configuration is shown in the image below.
The result is as follows:
{
"unsorted_list": [10, 6, 8, 12],
"sorted_list": [6, 8, 10, 12]
}
Text
Filtering an array of objects
For this example we will assume the following data:
{
"api": [{
"type": "rest",
"name": "Magento 2.4"
},
{
"type": "soap",
"name": "Magento 1.9"
},
{
"type": "rest",
"name": "Shopware 6.4"
}
]
}
Text
Now if we only want to keep the API objects where the type equals rest, we can utilize the filtering capability of JMESPath (documentation can be found here: JMESPath Examples — JMESPath) by applying the following transformation:
This brings us the following result:
{
"api": [{
"type": "rest",
"name": "Magento 2.4"
},
{
"type": "rest",
"name": "Shopware 6.4"
}
]
}
Text
Hopefully this information helped you understanding the basics of JMESPath. More information can be found over at https://jmespath.org/.
Best of luck implementing this within your integrations and feel free to share your own JMESPath tips and tricks below!
- Jesse Buitenhuis