Nifi - Jolt Transform JSON Processor - Create a JSON array by utilizing few fields of exiting JSON and ignore the null attributes while constructing the array
I'm a newbie to Nifi and learning eventually. I'm looking to create a JSON array by utilizing 5 fields of 15 fields JSON request by using JoltTransformJSON processor. JSON array must ignore the fields if the value is null/empty. @Matt Burgess
Input:
{
"lastName" : "cgLastName6",
"gender" : "Male",
"currentDate" : "20190509",
"middleInitial" : "D",
"address_2" : "fake addy 2",
"mailingZipCode" : "55555",
"provider_address_1" : "123 fake addy",
"color_1" : "white",
"color_2" : "",
"color_3" : "black",
"color_4" : "",
"color_5" : "blue",
"homeAddress" : "123 fake st",
"primaryLanguage" : "",
"country" : "us"
}
I'm trying to build JSON array of "color_* "attributes and current date parameter to followed by color. My output should consist of existing input + newly built JSON array which consists of 3 color as the color_2, color_4 are null.
Expected Output:
{
"lastName" : "cgLastName6",
"gender" : "Male",
"currentDate" : "20190509",
"middleInitial" : "D",
"address_2" : "fake addy 2",
"mailingZipCode" : "55555",
"provider_address_1" : "123 fake addy",
"color_1" : "white",
"color_2" : "",
"color_3" : "black",
"color_4" : "",
"color_5" : "blue",
"homeAddress" : "123 fake st",
"primaryLanguage" : "",
"country" : "us",
"colorsLove" : [ {
"color_1" : "white",
"date" : "20190905"
}, {
"color_3" : "black",
"date" : "20190905"
}, {
"color_5" : "blue",
"date" : "20190905"
}]
}

