Support Questions

Find answers, ask questions, and share your expertise

Need to format values from/in AttributesToJSON processor in Nifi

My AttributesToJSON outputs values this way from a hl7 file after going through ExtractHL7Attributes,


I want to format the above in this fashion,


Can it be achieved by using RegEx in properties or through any other processor. Please provide any sample case.

Thanks in advance.


@Vigneswar Gv Regex probably isn't the right solution here. Instead I'd recommend looking at one of the following:

There are pros and cons to each. Sometimes figuring out the right JOLT specification can be a little tricky but I think this [1] is close to what you're looking for. Solving this with a Groovy script should be pretty straightforward though since you always want to split the keys on the dots. You'll just need a recursive function that iterates through keys, pops off the leading content before the dot and merges it into a sub-entry.


Hi @jfrazee

Thanks for the response. I played around with JoltTransformJSON and was able to transform it from this,

{ "PID.PatientName.FamilyName": "Patient", "PID.PatientName.GivenName": "Test" }

to this,

{ "family": "Patient", "given": "Test" }

The JOLT specification i used was,


"operation": "shift",

"spec": {

"PID.PatientName.FamilyName": "family", "PID.PatientName.GivenName": "given"



However i wasn't able to include the part "name" in the json which was end result expected,


Can you advice of what should be done in JOLT spec to get the desired result ?

@Yolanda M. Davis @Yash

With input attributes like,

{ "PID.PatientName.FamilyName": "Patient", "PID.PatientName.GivenName": "Test", "PID.PhoneNumber.Home": "(123)456789"}

The final JSON formatted output will be looking something like the one below,

{"resourceType":"Patient","identifier":[{"use":"official","system":"urn:fake:mrns","value":"800001","assigner":{"display":"HealthCare Org"}}],"name":[{"family":"Patient","given":"Test12"}],"telecom":[{"system":"phone","value":"111-111-1111","use":"home"}]}

Expert Contributor

I'm not sure why you need an array around the name object - can you explain? Otherwise, you can achieve your desired result by putting "name" in front of your other sub-objects.

"operation": "shift",
"spec": {
"PID.PatientName.FamilyName": "", "PID.PatientName.GivenName": "name.given"

New Contributor

@Vigneswar Gv you always can use this debugger before use the processor to make sure it will work OK