Solved
Extracting List Elements using JOLT
Hello,
Could you assist me in retrieving the single branchName value from priceRuleAttributes list based on id,
When i am doing without id match its working fine and giving me single branchName value for each index but with id match its combining all values at 1st index.
Input
{
"Data": {
"ID": "09878666",
"DATE": "2022-01-01",
"ARRAY_ONE": [
{
"NAME": "test_1",
"priceRuleAttributes": [
{
"type": "CFA",
"id": "PR_BRANCH_NAME",
"values": [
"MEMBERS"
]
},
{
"type": "CFA",
"id": "PR_PRICE_RULE_PROMO",
"valueBoolean": true
},
{
"type": "CFA",
"id": "PR_TARGET_SEGMENT",
"values": [
"1"
]
}
]
},
{
"NAME": "test_2",
"priceRuleAttributes": [
{
"type": "CFA",
"id": "PR_BRANCH_NAME",
"values": [
"NON MEMBERS"
]
},
{
"type": "CFA",
"id": "PR_PRICE_RULE_PROMO",
"valueBoolean": true
},
{
"type": "CFA",
"id": "PR_TARGET_SEGMENT",
"values": [
"1"
]
}
]
}
]
}
}
Spec
[
{
"operation": "shift",
"spec": {
"Data": {
"ARRAY_ONE": {
"*": {
"@(2,ID)": "[#2].ID",
"@(2,DATE)": "[#2].DATE",
"NAME": "[#2].NAME",
"priceRuleAttributes": {
"*": {
"id": {
"PR_BRANCH_NAME": {
"@(2,values)": "[#4].branchName"
}
}
}
}
}
}
}
}
}
]
Expected Output
[ {
"ID" : "09878666",
"DATE" : "2022-01-01",
"NAME" : "test_1",
"branchName" : [ "MEMBERS" ]
}, {
"ID" : "09878666",
"DATE" : "2022-01-01",
"NAME" : "test_2",
"branchName" : [ "NON MEMBERS" ]
} ]
Actual output


