Home > Mobile >  Jolt Transformation for Object of Arrays
Jolt Transformation for Object of Arrays

Time:10-21

Please help!

i have a JSON data

{
  "id" : [ "295", "490", "1117", "3829", "Checksum" ],
  "event_name" : [ "How to bake Cookies", "Get rich quick", "Making money on YouTube", "Meditation for beginners", "bf0f71900d6745ad4333c962107a9c11" ],
  "date" : [ "2021-07-30", "2021-08-03", "2021-08-03", "2021-08-10", "" ],
  "number_of_attendees" : [ 417, 2000, 554, 20, "" ]
}

and i need to convert it into a separate object like

[
  {
    "id": "295",
    "event_name": "How to bake Cookies",
    "date": "2021-07-30",
    "number_of_attendees": "417"
  },
  {
    "id": "490",
    "event_name": "Get rich quick",
    "date": "2021-08-03",
    "number_of_attendees": "2000"
  },
  {
    so on .......
  }
]

CodePudding user response:

You can extend each array while separating by their respective levels through subindexes such as

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": { // the level of indexes of the arrays
          "@": "[&1].&2"
        }
      }
    }
  }
]

the demo on the site enter image description here

  • Related