NIFI JSON Jolt value mapping for keys

911 views Asked by At

I want to achieve following JSON transformation using Jolt processor in NIFI

input JSON

{
"street":"92 Lee St."
"state":"ON" 
"country":"CA"
}

Output JSON should be

{ 
"street":"92 Lee St."
"state":"Ontario"
"country":"Canada"
}

Is there a way to do this using existing Jolt operations or do I need to write custom operation?

Thanks.

1

There are 1 answers

0
mattyb On BEST ANSWER

There is no lookup method/operation in Jolt per se, but you might be able to use the matching operators to match "ON" for the "state" field and replace with "Ontario". However you'd have to have one rule per "lookup" and that might get messy.

You could write a custom Jolt operation, but it might be easier to try a technique from this related post in NiFi instead. Also you could pre-populate a DistributedCacheMapServer and use that (via a DistributedMapCacheClientService either in FetchDistributedMapCache or ExecuteScript) to get lookup values, for example.