1

我是新手。你能告诉我如何使用 jolt 根据位置将下面的 json 消息与数组转换为下面的输出 json 消息。

输入消息:

[
    ["20084541", "12020584", "Frohmann Dov", "2017", "2", "75", "T7", "DFZ", "CES", "", "", "0", "90", "2010"],
    ["20084541", "12020584", "Frohmann Dov", "2017", "3", "21", "T7", "DFZ", "CES", "", "", "0", "90", "2010"],
]

输出消息:

[{
    "policyReference": "20084541",
    "insuredId": "12020584",
    "insuredName": "Frohmann Dov",
    "uwy": "2017",
    "subLOB": "2",
    "typeOfRisk": "75",
    "aircraftcountryCode": "T7",
    "aircraftId": "DFZ",
    "manufacturerId": "CES",
    "aircraftTypeCode": "",
    "aircraftSubTypeCode": "",
    "aircraftValueAmt": "0",
    "aircraftWorkNo": "90",
    "yearBuilt": "2010"
}, {
    "policyReference": "20084541",
    "insuredId": "12020584",
    "insuredName": "Frohmann Dov",
    "uwy": "2017",
    "subLOB": "2",
    "typeOfRisk": "75",
    "aircraftcountryCode": "T7",
    "aircraftId": "DFZ",
    "manufacturerId": "CES",
    "aircraftTypeCode": "",
    "aircraftSubTypeCode": "",
    "aircraftValueAmt": "0",
    "aircraftWorkNo": "90",
    "yearBuilt": "2010"
}]

任何帮助表示赞赏。

4

1 回答 1

1

规格

[
  {
    "operation": "shift",
    "spec": {
      "*": { // loop thru the outer array
        // each item of the outer array, is an array
        // match individual array indicies, and then send them to the 
        //  output with the nice name.
        "0": "[&1].policyReference",
        "1": "[&1].insuredId",
        "2": "[&1].insuredName" 
        // etc
      }
    }
  }
]
于 2017-09-27T14:23:07.827 回答