Support Questions

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

Jolt Transformation IF and ELSE

avatar
Explorer

All,

I would like to create a new record based on the GroupTypeDescription. The value for this key could be "Individual" or "Enitity". Any help is appreciated

 

INPUT

{
"ConsolidatedList": [
              {
                 "AliasType": "Primary",
                 "AliasTypeName": "AKA",
                 "Country": null,
                 "CountryOfBirth": "Syria",
                 "GroupStatus": "Asset Tweaking",
                 "GroupTypeDescription": "Individual",
                 "ID": 33233,
                 "LastUpdated": "2021-03-15T00:00:00",
                 "LastUpdatedDay": 15,
                 "name1": "Larry",
                 "name2": "Dan"
    },
    {
                 "AliasType": "AKA",
                 "AliasTypeName": "AKA",
                 "Country": null,
                 "CountryOfBirth": "Afghan",
                 "GroupStatus": "Asset Freeze Targets",
                 "GroupTypeDescription": "Entity",
                 "ID": 33233,
                 "LastUpdated": "2021-03-15T00:00:00",
                 "LastUpdatedDay": 15,
                 "name1": "Luna",
                 "name2": "Daniel"
    }

]
}

 

EXPECTED OUTPUT

{
    "RecordType": ["Entity","Individual"],
    "Records": [
          {
               "_id": "1", // Counter
               "RecordType": "Entity",
               "Names": [
                     {
                       "_id": "1", //counter
                       "OtherName": "",
                       "UnparsedName": "",
                       "FirstName": "Luna",
                       "LastName": "Daniel",
                       "AliasType": "Primary"
                     }
                   ]
                },
                {
                       "_id": "2",
                       "RecordType": "Individual",
                       "Names": [
                              {
                                     "_id": "1",
                                     "OtherName": "",
                                     "UnparsedName": "",
                                     "FirstName": "Larry",
                                     "LastName": "Dan",
                                     "AliasType": "AKA"
                               }
             ]
  }
]
}

 

SPEC So far

[
{
       "operation": "shift",
              "spec": {
                   "ConsolidatedList": {
                           "*": {
                                    "GroupTypeDescription": "Records[0].RecordsType[&1]",
                                     "# ": "Records[0].Names.[&1].Other Name",
                                     "# ": "Records[0].Names.[&1].UnparsedName",
                                     "AliasType": "Records[0].Names.[&1].NameType"
                                  }
                          }
               }
        }
]

 

I need to split record into objects based on the recordType. Please ignore the first name and last name.

1 REPLY 1

avatar
Super Mentor

@Law 

 

While Jolt transforms are not something NiFi specific and not something I am strong with myself, you may find these links helpful to you:

https://intercom.help/godigibee/en/articles/3096940-simple-if-else-with-jolt
https://community.cloudera.com/t5/Community-Articles/Jolt-quick-reference-for-Nifi-Jolt-Processors/t...

Hope this helps,
Matt