I have a request object that points to an API from Stripe. The response from stripe looks like this
{
  "object": "list",
  "url": "/v1/refunds",
  "has_more": false,
  "data": [
    {
      "id": "re_3Jkggg2eZvKYlo2C0ArxjggM",
      "object": "refund",
      "amount": 100,
      "balance_transaction": null,
      "charge": "ch_3Jkggg2eZvKYlo2C0pK8hM73",
      "created": 1634266948,
      "currency": "usd",
      "metadata": {},
      "payment_intent": null,
      "reason": null,
      "receipt_number": null,
      "source_transfer_reversal": null,
      "status": "succeeded",
      "transfer_reversal": null
    },
    {...},
    {...}
  ]
}
I've created a decodable Request struct that looks like this:
struct Request: Decodable {
    var object: String
    var url: String
    var has_more: Bool
    var data: [Any]
}
The issue I am having is that the Request object can have data that contains an array of several different Objects. A refund object, a card object, and others. Because of this, I've added [Any] to the request struct but am getting this error:
Type 'Request' does not conform to protocol 'Decodable'
This seems to be because decodable can't use Any as a variable type. How can I get around this and use a universal Request object with dynamic object types?
 
     
    