Jolt add property at the top level to json

Viewed 103

I need to transform my JSON from REST API. I have:

[
  {
    "id": 59,
    "success": true,
    "errors": []
  },
  {
    "id": 18,
    "success": true,
    "errors": []
  }
]

How can i transform it to following JSON:

{
  "status": [
    {
      "id": 1812854,
      "success": true,
      "errors": []
    },
    {
      "id": 1815562,
      "success": true,
      "errors": []
    }
  ]
}

I need to add status at the top level to source JSON. Is it possible with JOLT?

1 Answers

You just can use the following shift transformation

[
  {
    "operation": "shift",
    "spec": {
      "*": "status"
    }
  }
]

enter image description here

Related