Object Transformer (ObjectTransformer)
The ObjectTransformer step allows you to shape and combine data from previous steps into a final JSON output (or intermediate format). It’s the perfect place to do last-minute data transformations or merges before returning results to the user.
Overview
When you define an ObjectTransformer step:
{
id: 'finalResult',
type: 'ObjectTransformer',
result: {
'@Extend': '$.results.someGenerator',
extraField: 'someValue',
},
}- id: Unique identifier (e.g.
finalResult). - type: Must be
ObjectTransformer. - result: An object that can contain references or operators (
@Map,@Extend, etc.). This is processed via the same Flow Language & JSON Path rules used elsewhere.
Why Use Object Transformer?
- Consolidate results from multiple steps into one final object.
- Rename or re-map fields using JSON Path.
- Combine data for your UI’s final display or for a subsequent step.
- Apply advanced transformations (like
@Map,@Index,@Extend) to reformat data from prior steps.
Example
{
id: 'finalResult',
type: 'ObjectTransformer',
result: {
'@Extend': '$.results.objectGeneratorStep',
info: {
modelUsed: '$.results.myTrainingStep.id',
images: '$.results.imageStep.images',
},
},
}Explanation:
- @Extend: merges the entire object from
objectGeneratorStepinto the final result. - modelUsed: references
myTrainingStep.id. - images: references
imageStep.images.
Final should look like:
{
someField: 'original data from objectGeneratorStep',
anotherField: 42,
info: {
modelUsed: 'uuid-of-the-model',
images: [{ url: '...' }, { url: '...' }],
},
}Step Definition
{
id: 'someTransformer',
type: 'ObjectTransformer',
result: {
mergedStuff: {
'@Extend': '$.results.stepA',
},
newArray: [
[
'@Map($.results.stepB.arrayField)',
{
title: '$$.title',
desc: '$$.description',
},
],
],
},
}The result field is processed with the Flow Language, so you can do everything from map loops to merging objects.
Parameters
Unlike other steps, ObjectTransformer uses:
• result (required): The structure you want to build or transform.
• No typical “settings” or “parameters” object is needed.
Internally, it just transforms or merges data and places it into results.[transformerId].
Common Use Cases
- Final Assembly: Combining all relevant pieces from your Flow into one object for UI display (like a summary page).
- Data Filtering: If you only need certain fields from a complex prior step, you can pick them out in result.
- Re-Structuring: Possibly you want to produce a simpler shape for an API or for a subsequent Zipper step.
- Intermediate: Sometimes you can have multiple ObjectTransformer steps chained if your data transformations are large or you prefer them in smaller chunks.
Last updated on