This example demonstrates obtaining an organized view of the given key-value pairs, which are initially presented in a mixed and unordered manner.

Sample Original Message

{
   "uId" : null,
   "data" : [
      {
         "id" : 2,
         "version" : 16,
         "code" : "234500001",
         "currency" : {
            "code" : "TL",
         },
         "detail" : "XXX,YYY",
         "matGroup" : {
            "id" : 676,
            "name" : "YYY",
            "otherName" : "YYY"
         },
         "matNsnCode" : null,
         "matType" : {
            "id" : 2,
            "name" : "ZZZ",
            "otherName" : "ZZZ"
         },
         "name" : "YYY / AAA",
         "prodUnit" : {
            "id" : 4,
            "otherName" : "BBB"
         },
         "matCategory" : "CCC",
         "materialCodeName" : "234500001 YYY",
         "materialUnit" : "BBB"
      }
   ],
   "total" : 11940
}
CODE

 

JOLT Code

[

  {
    "operation": "shift",
    "spec": {
      "data": { 
        "*": {
          "id": "data[#2].mat_id",
          "code": "data[#2].mat_code",
          "currency": {
            "code": "data[#3].mat_currency"
          },
          "detail": "data[#2].detail",
          "matGroup": {
            "id": "data[#3].matGroup_id",
            "name": "data[#3].matGroup_name"
          },
          "matNsnCode": "data[#2].matNsnCode",
          "matType": {
            "id": "data[#3].matType_id",
            "name": "data[#3].matType_name"
          },
          "prodUnit": {
            "otherName": "data[#3].prodUnit_otherName"
          },
          "matCategory": "data[#2].matCategory",
          "materialCodeName": "data[#2].mat_codeName",
          "materialUnit": "data[#2].matUnit",
          "contactInfo": {
            "email": "data[#3].source"
          }
        }
      }
    }
  },
  {
    "operation": "default",
    "spec": {
      "data[]": {
        "*": {
          "mat_id": null,
          "mat_code": null,
          "mat_currency": null,
          "detail": null,
          "matGroup_id": null,
          "matGroup_name": null,
          "matNsnCode": null,
          "matType_id": null,
          "matType_name": null,
          "prodUnit_otherName": null,
          "matCategory": null,
          "mat_codeName": null,
          "matUnit": null,
          "source": "SEM"
        }
      }
    }
  }
]
CODE

Sampe Result Message

{
  "data" : [ {
    "mat_id" : 2,
    "mat_code" : "234500001",
    "mat_currency" : "TL",
    "detail" : "XXX,YYY",
    "matGroup_id" : 676,
    "matGroup_name" : " YYY",
    "matNsnCode" : null,
    "matType_id" : 2,
    "matType_name" : "ZZZ",
    "prodUnit_otherName" : "BBB",
    "matCategory" : "CCC",
    "mat_codeName" : "YYY / AAA",
    "matUnit" : "BBB",
    "source" : "SEM"
  }
  ]
 }
CODE