Question
Copy Field value from one list to another using JOLT
Hello,
Could you please help me what i am missing here.. i am trying to copy currency value from currency condition and adding it in calculatePrice array.
Input
{
"tiers": [
{
"rewards": [
{
"rewardId": 8127,
"changeType": 2,
"changeAmount": 15,
"changePercent": null,
"quantityToDiscount": null,
"applyInd": 2,
"rewardsMerch": []
}
],
"priceRuleAttributes": [
{
"type": "CFA",
"id": "PR_CURR_CONDITION",
"values": [
"AED"
]
}
]
},
{
"rewards": [
{
"rewardId": 8128,
"changeType": 2,
"changeAmount": 18,
"changePercent": null,
"quantityToDiscount": null,
"applyInd": 2,
"rewardsMerch": []
}
],
"priceRuleAttributes": [
{
"type": "CFA",
"id": "PR_CURR_CONDITION",
"values": [
"USD"
]
}
]
}
]
}Spec
[
{
"operation": "shift",
"spec": {
"tiers": {
"*": {
"priceRuleAttributes": {
"*": {
"id": {
"PR_CURR_CONDITION": {
"@(2,values[0])": "paths.[&5].currencyCondition[#2].currency"
}
}
}
},
"rewards": {
"*": {
"changeType": "paths.[&3].calculatePrice[&1].calculationType",
"changeAmount": "paths.[&3].calculatePrice[&1].amount",
"changePercent": "paths.[&3].calculatePrice[&1].percentage"
}
}
}
}
}
},
{
"operation": "modify-default-beta",
"spec": {
"paths": {
"*": {
"calculatePrice": {
"*": {
"currency": "@(0,currencyCondition[&].currency)"
}
}
}
}
}
}
]Expected output
{
"paths" : [ {
"currencyCondition" : [ {
"currency" : "AED"
} ],
"calculatePrice" : [ {
"calculationType" : 2,
"amount" : 15,
"percentage" : null,
"currency" : "AED"
} ]
}, {
"currencyCondition" : [ {
"currency" : "USD"
} ],
"calculatePrice" : [ {
"calculationType" : 2,
"amount" : 18,
"percentage" : null,
"currency" : "AED"
} ]
} ]
}

