Reputation: 25
I am attempting to merge two flowfiles together using MergeContent. The content of both files are JSON objects which I would like to append to each other and wrap both with a JSON key.
File 1:
"Create":[
{
"Action": "Create",
"Book": {
"Id": "1234"
}
},
{
"Action": "Create",
"Video": {
"Id": 3245
}
}
]
File 2:
"Update":[
{
"Action": "Update",
"Book": {
"Id": "5376"
}
},
{
"Action": "Update",
"Video": {
"Id": "8267"
}
}
]
I need the final output to look like so:
{
"Transaction": {
"Action": "Transaction",
"Type": {
"Create": [
{fill in stuff}
],
"Update": [
{fill in stuff}
]
}
}
}
What is happening is that my MergeContent processor is picking up more than one flow file out of the Update or Create input and it is merging 'like' flow files together, instead of merging the separate content together.
Screenshot of my MergeContent :
Upvotes: 1
Views: 435
Reputation: 65408
You can add a MergeContent
processor with
Delimiter Strategy
= Text
Header
= {
Footer
= }
Demarcator
= ,
in order to generate the core part
"Create": [
{fill in stuff}
],
"Update": [
{fill in stuff}
]
then apply a JSONJoltTransform
with specification
[
{
"operation": "shift",
"spec": {
"#Transaction": "&.Action",
"@": "Transaction.Type"
}
}
]
in order to convert them to a formatted JSON value as desired such as
Upvotes: 0