You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code produces a Fatal error: unimplemented error when container.nestedContainer is called. Looking at the code I can see also nestedUnkeyedContainer isn't implemented.
import PureSwiftJSONCoding // fabianfett/pure-swift-json
struct Object: Encodable {
let firstName: String
let surname: String
init(firstName: String, surname: String) {
self.firstName = firstName
self.surname = surname
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
var nameContainer = container.nestedContainer(keyedBy: NameCodingKeys.self, forKey: .name)
try nameContainer.encode(firstName, forKey: .firstName)
try nameContainer.encode(surname, forKey: .surname)
}
private enum CodingKeys: String, CodingKey {
case name = "name"
}
private enum NameCodingKeys: String, CodingKey {
case firstName = "firstName"
case surname = "surname"
}
}
let object = Object(firstName: "Adam", surname: "Fowler")
let json = try JSONEncoder().encode(object)
The text was updated successfully, but these errors were encountered:
The following code produces a
Fatal error: unimplemented
error whencontainer.nestedContainer
is called. Looking at the code I can see also nestedUnkeyedContainer isn't implemented.The text was updated successfully, but these errors were encountered: