简体   繁体   中英

Json with array transformation based upon position using jolt

Iam new to jolt. Can you please tell me how can i trasform the below json message with array based upon the position in to the below output json message using jolt.

input message :

[
    ["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"],
]

output Message :

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

Any help appreciated.

Spec

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM