Created on 09-22-2020 10:39 PM - edited 09-22-2020 10:45 PM
Hi,
I have below JSON file with multiples image's details
{
"images": [{
"id": "C2934",
"ds_folder_id": "759838458734"
},
{
"id": "C8343",
"folder_id": "3942879137986"
}]
}.
I have id of the image and have to update the folder_id with some value.
For Example:
id is C8343 and the new folder_id is 2984584735
then I have to update folder_id of the JSON file with new one.
New JSON would be
{
"images": [{
"id": "C2934",
"ds_folder_id": "759838458734"
},
{
"id": "C8343",
"folder_id": "2984584735"
}]
}.
Please help me to perform above in NiFi.
Created 09-23-2020 04:50 PM
@ravi_sh_DS The solution you are looking for is UpdateRecord.
Here is a great article with full info:
If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.
Thanks,
Steven
Created 09-23-2020 04:50 PM
@ravi_sh_DS The solution you are looking for is UpdateRecord.
Here is a great article with full info:
If this answer resolves your issue or allows you to move forward, please choose to ACCEPT this solution and close this topic. If you have further dialogue on this topic please comment here or feel free to private message me. If you have new questions related to your Use Case please create separate topic and feel free to tag me in your post.
Thanks,
Steven
Created 09-23-2020 09:59 PM
thanks ! @stevenmatison for the detailed explanation. 🙂
Created 09-24-2020 12:27 AM
Hi @stevenmatison,
Thanks, but I have to make a judgemental update in JSON. As I explained in the example only id with a particular value will be updated.
Please assist.
Created 09-24-2020 05:56 AM
@ravi_sh_DS This gets a bit high level, so forgive me, as I am not sure how you know which ID to change and what to change it too. That said, your approach could be to use QueryRecord and find the match you want, then update that match with UpdateRecord. You can also split the json image array with SplitJson, then use UpdateRecord as suggested above. In either method depending on your Use Case when you split the records and process the splits separately you may need to rejoin them downstream.
Some older methods useful here are SplitJson, EvaluateJson, UpdateAttribute, AttributeToJson, but the Query Update Records are now preferred as it is possible to do things more dynamically.