Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to add a key - value to JSON in Nifi?

avatar
Explorer

I have a JSON

{
"name": "abc",
"age": 14,
"data": {
    "course": "math",
    "score": 90
}
}


I want to add a new key - value (year, 2019) at the end of this JSON. How can I achieve that in Nifi?

Desired output:

{
"name": "abc",
"age": 14,
"data": {
    "course": "math",
    "score": 90
},
"year": 2019
}
2 REPLIES 2

avatar
Master Guru

You can use UpdateRecord for this, add a user-defined property called "/year" with a Replacement Strategy of "Literal Value" and a value of 2019. Note that your Record Writer's schema should have the "year" field in it.

avatar
New Contributor