jsonjolt

Need Jolt transform with below


Hi I'am trying a jolt transform of below

{
  "Others": {
    "eventTime": "2024-09-05T01:50:05.861",
    "groupArticleNumber": "IW6012",
    "groupModelNumber": "JSO42",
    "seasonCode": "20242"
  },
  "x": [
    {
      "materialComposition": "100% PET-REC",
      "mainMaterialFlag": true
    }
  ],
  "y": [
    {
      "sourcingSizeCode3": "550"
    },
    {
      "sourcingSizeCode3": "540"
    }
  ]
}

and the expected output as

[
  {
    "eventTime": "2024-09-05T01:50:05.861",
    "groupArticleNumber": "IW6012",
    "groupModelNumber": "JSO42",
    "seasonCode": "20242",
    "materialComposition": "100% PET-REC",
    "mainMaterialFlag": true,
    "sourcingSizeCode3": "550"
  },
  {
    "eventTime": "2024-09-05T01:50:05.861",
    "groupArticleNumber": "IW6012",
    "groupModelNumber": "JSO42",
    "seasonCode": "20242",
    "materialComposition": "100% PET-REC",
    "mainMaterialFlag": true,
    "sourcingSizeCode3": "540"
  }
]

I need a jolt spec for same. I have tried so many spec trying multplexing aslo but no luck.


Solution

  • Hi hope this spec helps you resolve your query.

    [
      {
        "operation": "shift",
        "spec": {
          "y": {
            "*": {
              "sourcingSizeCode3": "[#2].sourcingSizeCode3",
              "@(2,Others)": {
                "*": "[#3].&"
              },
              "@(2,x)": {
                "*": {
                  "*": "[#4].&"
                }
              }
            }
          }
        }
      }
    ]
    

    enter image description here