How to Decode JSON in Swift 4?
问题 How to decode following json using Swift 4? { "data": { "id": 22, "packageId": 5, "Package": { "id": 5, "color": "blue" } }, "error": false, "message": "Successfully Fetched" } I have tried it using following: struct Root: Codable { enum CodingKeys: String, CodingKey { case id = "id" case packageId = "packageId" case package = "Package" } var package : Package var id : Int var packageId : Int } struct Package : Codable { var id : Int var color : String } It is giving me following error: