Support Questions
Find answers, ask questions, and share your expertise
Alert: Please see the Cloudera blog for information on the Cloudera Response to CVE-2021-4428

Deserialize JSON Data from FetchDistributedCacheMap to merge into flow file

New Contributor

Extracting Json data from an Attribute variable
I have a flow file that needs to be enriched, So I have created an api that can be called the resulting json is then stored to an attribute and a DistributedCacheMap record is then written using PutDistributedMapCache to avoid repeated calls to the api for the same device as flow files arrive.

KV pair looks like this
Key DeviceName=ABC123  Value = {"device":"ABC123","State":"NSW","location":"SYD55"}

When Flow files are being processed a lookup is done to see if the device data is already in the DistributedMapCache if it is an attribute called cached-value is then assigned using process FetchDistributedMapCache the resulting Attribute variable comes back looking like this.
cached-value :{"device":"ABC123","State":"NSW","location":"SYD55"}

What I need to do then is extract the json from the cached-value attribute and merge it back into the flow file to enrich the data within that flow file. I am struggling to find a way to deserialise this json from the cached-value to use it back in the flow file. Have tried AttributesToJson without any luck

Any suggestions would be appreciated.