bazaarvoice / jolt

JSON to JSON transformation library written in Java.
Apache License 2.0
1.55k stars 330 forks source link

How to replace inner object with just one value? #1222

Open dhoffer opened 11 months ago

dhoffer commented 11 months ago

I have a nested JSON object structure where at the innermost object (and the field name ends with 'Tag') I want to replace that object with just the value if its 'value' field. I also want to remove the Tag suffix from the field name.

I'm trying to transform this:

"safeguardingAndSharingTagArea": { "usageRightsTagClass": { "usageRightsTag": { "value": "R5", "tagValueSources": [ "CONFIG" ], "defaultValue": null, "required": false } }, "specialControlsTagClass": { "controlsTag": { "value": "H4", "tagValueSources": [ "CONFIG", "PAYLOAD_OVERRIDE" ], "defaultValue": null, "required": false } },

Into this:

"safeguardingAndSharingTagArea": { "usageRightsTagClass": { "usageRights": "R5" }, "specialControlsTagClass": { "controls": "H4" },

How can I do this with Jolt?

Thanks, -Dave