Home > Mobile >  Jolt transform: extract nested array from an object
Jolt transform: extract nested array from an object

Time:10-20

I have JSON Input as below

{
  "data": [
    {
      "items": [
        {
          "item": "R11",
          "code": "8611A"
        },
        {
          "item": "R2",
          "code": "8611B"
        }
      ]
    }
  ]
}

I need to extract items array as below

[
  {
    "item": "R11",
    "code": "8611A"
  },
  {
    "item": "R2",
    "code": "8611B"
  }
]

Please copy and paste the above INPUT and OUTPUT enter image description here

CodePudding user response:

Alternative Spec:

[
  {
    "operation": "shift",
    "spec": {
      "data": {
        "*": {
          "items": ""
        }
      }
    }
  }
]

CodePudding user response:

Here is the answer

    [{
  "operation": "shift",
  "spec": {
    "data": {
      "0": {
        "*": ""
      }
    }
  }
}]
  • Related