Data Transformation

With DocuMotor we can transform JSON data using JMESPath. It is possible to perform simple operations like combining the values of two fields like first name and last name. Moreover, complex operations like calculations and filtering can also be achieved. This section will provide insight into these operations.

Before starting to transform your data into useable output for the template bindings, here are some general guidelines to consider when doing transformations:

Firstly, consider the entire output before starting to do the transformations. For instance, if you have a slide containing various different fields and perhaps a table, then consider if the transformations you are doing are only needed for the element you are focusing on or if it needs to be used again for other parts of the output at a later stage.

Secondly, try to make your own transformations as readable as possible. You never know who might need to take a look in the future to make amends. To help with this make comments in the code by writing “//” in front of your comment.

Finally, you should think about having your post transformation data output as clean as possible. Only transform the stuff you actually need, and if you can do the transformation in 1-2 lines of code do not use 10. In this also think about repeating variables, the more repeating variables you have the more likely it is that you can cut down on your transformation with the proper use of piping “|”.