1
votes

I need to do a string concatenation on the element in 7 and 8th position in an array as aircraft id and create a json message using jolt.Below is the sample spec,input,actual output and expected output.Can you please help iam using jolt framework version 0.0.20

Input :

[
  [
    "20083366",
    "12018098",
    "Air Transport Europe",
    "2017",
    "1",
    "60",
    "OM",
    "ATM",
    "Test",
    "",
    "",
    "7600000",
    "",
    "0"
  ],
  [
    "20083366",
    "12018098",
    "Air Transport Europe",
    "2017",
    "2",
    "75",
    "OM",
    "ATM",
    "",
    "",
    "",
    "7600000",
    "",
    "0"
  ]
]

Jolt Spec :

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "7": "[&1].countryCodeAircraftId",
        "8": "[&1].aircraftId",
        "9": "[&1].aircraftTypeCode",
        "1": "[&1].insuredId",
      }
    }
  },
  {
    "operation": "modify-default-beta",
    "spec": {
      "*": {
        "14": "=concat(@(1,countryCodeAircraftId),' ',@(1,aircraftId))"
      }
    }
  }
]

Actual output:

[ {
  "countryCodeAircraftId" : "ATM",
  "aircraftIds" : "Test",
  "aircraftTypeCode" : "",
  "insuredId" : "12018098",
  "aircraftId" : "ATM Test"
}, {
  "countryCodeAircraftId" : "ATM",
  "aircraftIds" : "",
  "aircraftTypeCode" : "",
  "insuredId" : "12018098",
  "aircraftId" : "ATM "
} ]

Expected output:

[ {
  "aircraftId" : "ATM Test",
  "aircraftTypeCode" : "",
  "insuredId" : "12018098"
}, {
  "aircraftId" : "",
  "aircraftTypeCode" : "",
  "insuredId" : "12018098",

} ]
1

1 Answers

0
votes

Jolt version 0.0.20 does not have the "modify-default-beta" operation. It was added in 0.0.22.