Json转换使用数组中的jolt字符串连接

时间:2017-11-06 16:01:14

标签: json jolt

我需要对数组中第7位和第8位的元素进行字符串连接作为飞机id并使用jolt创建json消息.Below是样本规格,输入,实际输出和预期输出。可以请你帮忙 我使用jolt框架版本0.0.20

输入:

[
  [
    "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))"
      }
    }
  }
]

实际输出:

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

预期产出:

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

} ]

1 个答案:

答案 0 :(得分:0)

Jolt版本0.0.20没有" modify-default-beta"操作。它被添加到0.0.22。