Created 07-05-2022 08:27 AM
Hello everyone,
i need your help. I am relatively new to nifi and need your help. I am using the processor ConsumeKafkaRecord_2_6 1.15.3 with the record writer json set record writer. The output is then an array without object name. Which processor or setup can I use to add an array name to the json output? I get this Output
[ {
"moving_id" : 17078440,
"store_id" : 9,
"gtin" : 4064813288877,
"qty" : -1.0,
"condition_indicator" : 40,
"issue_date" : 1656585240000,
"received_date" : 1656547200000,
"update_date" : 1656578057133
}, {
"moving_id" : 17078441,
"store_id" : 9,
"gtin" : 4064813288907,
"qty" : -1.0,
"condition_indicator" : 40,
"issue_date" : 1656585240000,
"received_date" : 1656547200000,
"update_date" : 1656578057133
} ]
and i need json file in this structur
{"stocks":
[ {
"moving_id" : 17078440,
"store_id" : 9,
"gtin" : 4064813288877,
"qty" : -1.0,
"condition_indicator" : 40,
"issue_date" : 1656585240000,
"received_date" : 1656547200000,
"update_date" : 1656578057133
}, {
"moving_id" : 17078441,
"store_id" : 9,
"gtin" : 4064813288907,
"qty" : -1.0,
"condition_indicator" : 40,
"issue_date" : 1656585240000,
"received_date" : 1656547200000,
"update_date" : 1656578057133
} ]}
Created 07-05-2022 09:23 AM
Hi,
You can use the JoltTransformJson Processor and set the Jolt Specification value to :
[
{
"operation": "shift",
"spec": {
"*": "stocks[]"
}
}
]
Hope that helps. If it does, Please accept solution. Thanks
Created 07-05-2022 09:23 AM
Hi,
You can use the JoltTransformJson Processor and set the Jolt Specification value to :
[
{
"operation": "shift",
"spec": {
"*": "stocks[]"
}
}
]
Hope that helps. If it does, Please accept solution. Thanks
Created 07-06-2022 01:50 AM
Thank you, this approach works well
Created 07-05-2022 03:30 PM
What are you trying to do with the stock records after that step in your flow?
Cheers,
André
Created 07-06-2022 01:54 AM
@araujothe next step is with InvokeHTTP processor to update the stocks of products via Rest Endpoint