json - Decoding a nested array using Codable structs in Swift 4 is only working with an array size of 1 -


i have json payload formatted this:

{     items: [        {           id: 1,           anotherkey: anothervalue        },        {           id: 2,           anotherkey: anothervalue        }     ] } 

this code using decode payload:

   struct suggestions : codable {         let items: [employeedto]     }      if let json = try? jsondecoder().decode(suggestions.self, from: response.data!) {         print("decoding success, json \(json)")     }     else {         print("failed")     } 

my employeedto defined in external file codeable struct well. problem running decoding works if array has 1 result. in other words, array of 1 single employeedto object. have array of 2 or more objects, decoding fails , goes straight else. ideas on why happens? stumped. document have been using guide parsing nested objects arrays: http://benscheirman.com/2017/06/ultimate-guide-to-json-parsing-with-swift-4/


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -