Reactive icon

JSONata Transformation

Stable version 1.2.0 (Compatible with OutSystems 11)
Published on 25 Jan by 
 (0 ratings)

JSONata Transformation


JSONata is a JSON document transformation and manipulation library. It is especially useful when you have to deal with dynamic JSON data returned from an REST API. JSONata allows you to transform that dynamic result to a structured result to have it deserialised to an OutSystems structure.


Lets take a look at the following JSON document

* (How do i add code here ?)

Look at data.keys. Keys holds a dictionary with a number as the key. In addition the value of that key is either an object or (for 3) just a number.

The goal is now to transform this JSON to something like this

Here we transformed the dictionary to an array. We also added the key of the dictionary as version to the object element and we solved the problem of having sometimes an object and sometimes just a number. In order to get there we need to write a JSONata transform. For the example above we use this one

This JSONata transformation transforms the data.keys element leaving all other properties as they are. Please see the JSONata documentation for additional transformation functions and manipulation options.

How to use

Add a depencency to Json_Transform of the JSONata_IS module

The Json_Transform server action takes the original JSON document (as string) and the transform document (as string) as input.

If transformation succeeds it returns IsSuccess = true. Otherwise it returns false and the Error Output contains the error message.

The Result output parameter contains the transformed Json. You can now deserialize that to an OutSystems structure.

Happy Low Coding!