Home > other >  Mapping values in jolt
Mapping values in jolt

Time:11-25

I am trying to map three fields in JOLT.

Below are the fields and the path I want to map the values with

PO_ID with integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityDetails.poDetails.externalId

WG_REQ_ID with integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityDetails.poDetails.poHeader.poDescription

FREIGHT_TERMS with integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityDetails.poDetails.poHeader.deliveryTermCode

I want to know what the JOLT Spec would look like.

Input JSON

{
  "PURCHASE_ORDER_DISPATCH": {
    "MsgData": {
      "Transaction": {
        "PO_POD_HDR_EVW1": {
          "VENDOR_SETID": "WCOS",
          "PO_ID": 25052,
          "PO_POD_LN_EVW1": {
            "WG_REQ_ID": 25694,
            "PO_POD_SHP_EVW1": {
              "FREIGHT_TERMS": "FOBDEST",
              "BUSINESS_UNIT": "OFIC"
            }
          }
        }
      }
    }
  }
}

Expected Output

{
  "integration-inbound:IntegrationDetails": {
    "integrationEntities": {
      "integrationEntity": {
        "integrationEntityHeader": {
          "action": "UPSERT"
        },
        "integrationEntityDetails": {
          "poDetails": {
            "poHeader": {
              "poDescription": 25694,
              "deliveryTermCode": "FOBDEST",
              "externalId": 25052
            }
          }
        }
      }
    }
  }
}

CodePudding user response:

You can use this simple spec:

[
  {
    "operation": "shift",
    "spec": {
      "#UPSERT": "integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityHeader.action",
      "*": {
        "*": {
          "*": {
            "*": {
              "PO_ID": "integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityDetails.poDetails.poHeader.externalId",
              "*": {
                "WG_REQ_ID": "integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityDetails.poDetails.poHeader.poDescription",
                "*": {
                  "FREIGHT_TERMS": "integration-inbound:IntegrationDetails.integrationEntities.integrationEntity.integrationEntityDetails.poDetails.poHeader.deliveryTermCode"
                }
              }
            }
          }
        }
      }
    }
  }
]
  • Related