This is a map-type SmartModule that transforms JSON records leveraging Fluvio Jolt library, which has its own DSL (Domain Specific Language) to remove the need for coding simple transformations.
The transformations in Jolt are a set of operations that are sequentially performed over incoming records.
There are three main types of operations:
Shift - move the field from one location to another
Default - specify a default value for the field, if not present
Remove - delete the field from the object
There can be a mix and match of transformations applied at the same time. Let’s see below:
Specification example
[{"operation":"remove",// remove field $.id from incoming JSON object
"spec":{"id":""}},{"operation":"shift",// move everything inside $.data
"spec":{"*":"data.&0",}},{"operation":"default",// if $.data.source does not exist, add it with value "http-connector"
"spec":{"data":{"source":"http-connector"}}}]
The Jolt SmartModule applies the operations in sequence: remove followed by shift followed by default.