Hi James,

Have you tried the FlattenJson processor? It covers exactly your scenario, 
perhaps with some tweaking to field names needed.

Regards,

Isha

Van: James McMahon <jsmcmah...@gmail.com>
Verzonden: woensdag 9 maart 2022 20:47
Aan: users@nifi.apache.org
Onderwerp: Transforming json

Hello. I am not that familiar with NiFi JSON processors, and am hoping someone 
can help me with a requirement to transform and parse incoming json. The 
biggest challenges for me here are that the keys in my incoming final_results 
can vary in number, and I need to use actual key names to form my json output 
results.

Here is a dummied up representation of an incoming object:
{
     "bigStructure":{
       .
       .
       .
          "final_results": {
               "Label1": {
                    "color": "red,
                    "temp": "0C"
                },
               "AnotherLabel": {
                    "color": "blue,
                    "temp": "32F"
                },
                 .
                 .
                 .
               "LastLabel": {
                    "color": "black,
                    "temp": "0K"
                }
          },
          "ID": "12345",
          "lastUpdated": "20220309"
       }
}

Here is what I need to generate as my output object:
{
     "Label1.color": "red",
     "Label1.temp": "0C",
     "AnotherLabel.color": "blue",
     "AnotherLabel.temp": "32F",
     "LastLabel.color": "black",
     "LastLabel.temp": "0K",
     "ID": "12345",
     "lastUpdated": "20220309"
}

I gather that this transformation needs to happen because they feed that output 
structure into a database that expects the data in this format.

Can I do this with "out of the box" nifi processors? Any help is much 
appreciated.
Thank you in advance!

Reply via email to