bazaarvoice / jolt

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

Iam very much new to Jolt, Could you please help me to tranform below Json #1069

Open testaccount899 opened 3 years ago

testaccount899 commented 3 years ago

Input

{ "consents": [ { "consent-data": [ { "consent-key": "DOB", "consent-value": "02/2006" } ], "consent-id": "123", "consent-indicator": "true", "consent-type": "COPPA", "resource-id": "456" }, { "consent-data": [ { "consent-key": "DOB", "consent-value": "02/2006" } ], "consent-id": "567", "consent-indicator": "true", "consent-type": "COPPA", "resource-id": "678" } ] }

Output

{ "Consents": [ { "consentDataResponse": [ { "consentKey": "DOB", "consentValue": "02/2006" } ], "consentId": "123", "consentIndicator": "true", "consentType": "COPPA", "resourceId": "456" }, { "consentDataResponse": [ { "consentKey": "DOB", "consentValue": "02/2006" } ], "consentId": "567", "consentIndicator": "true", "consentType": "COPPA", "resourceId": "678" } ] }

Note - No.of Consent arrays and consentDataResponse might be repeated

testaccount899 commented 3 years ago

Can some one help me Here pls

testaccount899 commented 3 years ago

Current Transformtion

[ { "operation": "shift", "spec": { "consents": { "": { "consent-id": "consents[&1].retailerId", "consent-indicator": "consents[&1].consentIndicator", "consent-type": "consents[&1].consentType", "resource-id": "consents[&1].resoureId", "consent-data": { // loop thru the orderItems array "": { "consent-key": "consentDataResponse[&1].consentKey", "consent-value": "consentDataResponse[&1].consentValue" } } } } } }

]