YAWE integrates in its READ endpoints JSONata, a library that allows you to query, filter, sort and transform your data! (and more!)
To check the oficial documentation please visit their website, https://docs.jsonata.org/overview.html.
On this page you will find a quick starting guide to use JSONata expressions for the most common usages.
JSONata version: 1.8.4
The JSONata expression is sent in the URL using the parameter jsonata, we recommend to encode the expression to ensure that special characters are sent properly in the request.
- Only READ endpoints accept JSONata expressions.
- The expression is evaluated using the result of the read operation. You need to take into account when using other parameters like dataOnly or uniqueId.
JSONata helps us solve the most common cases when it comes to extracting data from JSON. Here you can find some basic expressions.
We will use the following JSON to test our expressions.
You can try out these expressions at https://try.jsonata.org.
Gets an array of names.
Gets the second element.
Gets the name of the first element.
Filters records in the array containing the path data.name and matching Eduardo.
Filters records in the array containing the path data.jobDetails.
Filters records in the array with data.age between 16 and 20.
Gets the first 2 elements.
Gets the second 2 elements.
Sorts the results by ascending age. In this expression we use the $sort function to sort the results.
$toMillis converts a ISO 8601 date to milliseconds. In this example we filter all the elements created after 2021-02-07 22:00:00.