Suppose the JSON initially looks like:

jsonData := {
  "type": "text",
  "contents": []
}
contentsjsonData
{
      "type": "bubble",
      "hero": {
        "size": "full"
      },
      "body": {
        "spacing": "sm",
        "contents": [
          {
            "size": "xl"
          },
          {
            "type": "box",
            "contents": [
              {
                "flex": 0
              },
              {
                "flex": 0
              }
            ]
          }
        ]
      },
      "footer": {
        "spacing": "sm",
        "contents": [
          {
            "type": "button",
            "action": {
              "type": "uri"
            }
          },
          {
            "type": "button",
            "action": {
              "type": "uri"
            }
          }
        ]
      }
    },

Finally output looks like this :

jsonData := {
      "type": "text",
      "contents": [{......},{.......}]
    }