0

My service expects two possible json input.

The final output JSON object of the happy scenario is in the following format (I guess its an object?), which is the correct format. But, when it enters the error jolt logic, its been discarded and I get a final output of null for the overall happy scenario. HEnce, if I can get jolt to skip the error operations then we are good

    [
          {
            "loanId": 1111111,
            "status": "APPROVED",
            "amount": 10000,
            "currency": null
          },
          {
            "loanId": 22222222,
            "status": "APPROVED",
            "amount": 10000,
            "currency": null
          }
    ]

The main jolt input for the happy scenario is below, we manipulate and add some nulls as default:

[
  {
    "loanId": 1111111,
    "status": "APPROVED",
    "amount": 10000
  },
  {
    "loanId": 22222222,
    "status": "APPROVED",
    "amount": 10000
  }
]

The error scenario JSON input has the following Json format (I guess its an array?). But, the jolt scripts works end to end for the error input:

{
  "err" : {
    "x" : "x",
    "is_error" : [ "f", "f", "f", "f", "f", "f" ],
    "is_reject" : "t",
    "reference" : null,
    "repayment" : null,
    "fees" : null,
    "token" : null,
    "url" : null,
  }
}

The jolt input for the error scenario is below:

{
  "errors": [
    {
      "code": 1001,
      "status": "As you have .."
    },
    {
      "code": 1002,
      "status": "No LAST_NAME Found in request"
    },
    {
      "code": 1003,
      "status": "No EMAIL ID Found in request"
    },
    {
      "code": 1004,
      "status": "No PHONE NUMBER Found in request"
    },
    {
      "code": 1005,
      "status": "No BIRTHDATE Found in request"
    }
  ]
}

I have crafted a jolt spec but it only works for the error input as stated earlier.

How can I get the below jolt spec to bypass the happy path input? i.e. bypasses the object [{},{}], so that it works only on the {"err":[...]} input

My Jolt Specification is below:

// All the jolt operations below should only get triggered for the {"errors":[...]} input.

//For the happy path, the transformation before the script below (not in this post) is sufficient

  {
    "operation": "shift",
    "spec": {
      "err": {
        "*": "&",
        "lender_status": null,
        "is_reject": {
          "t": {
            "#REJECT": "lender_status",
            "#Rejection reason ...": "lender_status_details"
          }
        }
      }
    }
  },
  {
    "operation": "remove",
    "spec": {
      "x": "",
      "is_error": ""
    }
  },
  {
    "operation": "default",
    "spec": {
      "lender_status": "ERROR",
      "lender_status_details": "Might be missing field"
    }
  }
Mega
  • 1,304
  • 5
  • 22
  • 37

0 Answers0