Home > Mobile >  Decoding JSON data without key swift
Decoding JSON data without key swift

Time:02-02

I am trying to decode json data from an api in my swift app. However there is no key as the data returned is just an array. I have attached a screenshot of the response. How would I decode this data. enter image description here

CodePudding user response:

Array decoding:

 struct NameStruct: Codable {
                let data: [DataBody]
    }
    struct DataBody: Codable {
                let value: String
           
    }

CodePudding user response:

 struct NameObject: Codable {
     let item: [String]
   }
  •  Tags:  
  • Related