I am trying to decode an array of my model objects(Catalog) from a JSON that looks like this after serialization of corresponding 'Data' object.
 { "id" : 5,
   "catalogs" : [ {catalogKeyValue1},{catalogKeyValue2}]
 }
My model object looks like this
struct Catalog : Codable{
 var id : Int
 var name : String
 var categoryId : Int
 var minProductPrice : Int
 var maxProductDiscount : Int?
 var shareText : String
 var collageImage : String
 var collageImageAspectRatio : Double?
 var shipping : [String : Int]?
 var description : String
}
I need to get an array of Catalogs (which is nested against 'catalogs' key in JSON) after decoding.I fully understand using nested containers and writing custom initialaizer for Catalog struct .How can I achieve this without having to write another Codable struct for outer JSOn that looks like this
struct CatalogArray: Codable {
 var catalogs : [Catalog]
}
and then do something like this to get a decoded array of Catalogs
let catalogArray = try decoder.decode(CatalogArray.self, from: validData)
My problem is I dont have any need for this catalogArray struct. Is there a way of getting Catalog model objects decoded without having to create unnecessary nested structs.
 
     
    