I want to use if loop for below scenario in JOLT.
Like if WG_SHIP_ADDR_TYPE
value is 2 then
map
DESCR_SHIPTO
to addressName
and
ADDRESS1_SHITPTO
to addressLine
If it is possible in jolt then what would the spec look like?
Below is the code
Input
{
"PURCHASE_ORDER_DISPATCH": {
"MsgData": {
"Transaction": {
"PO_POD_HDR_EVW1": {
"PO_POD_LN_EVW1": {
"PO_POD_SHP_EVW1": {
"WG_SHIP_ADDR_TYPE": 2,
"DESCR_SHIPTO": "OHIOFARMERSINSURANCECOMPANY",
"ADDRESS1_SHIPTO": "OHIO FARMERS INSURANCE COMPANY"
}
}
}
}
}
}
}
Expected Output
{
"integration-inbound:IntegrationDetails": {
"integrationEntities": {
"integrationEntity": {
"integrationEntityHeader": {
"action": "UPSERT"
},
"integrationEntityDetails": {
"poDetails": {
"poHeader": {
"shipToAddress": {
"addressName": "OHIOFARMERSINSURANCECOMPANY",
"addressLine": "OHIO FARMERS INSURANCE COMPANY"
}
}
}
}
}
}
}
}
CodePudding user response:
You can use this spec
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": {
"*": {
"*": {
"*": {
"WG_SHIP_ADDR_TYPE": {
"2": {
"#UPSERT": "integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityHeader.action",
"@(2,DESCR_SHIPTO)": "integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityDetails.poDetails.poHeader.shipToAddress.addressName",
"@(2,ADDRESS1_SHIPTO)": "integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityDetails.poDetails.poHeader.shipToAddress.addressLine"
}
}
}
}
}
}
}
}
}
}
]