Closed irace closed 8 years ago
I can’t figure out for the life of me why the following does not work:
struct Foo: Decodable { let bar: String? static func decode(object: AnyObject) throws -> Foo { return try Foo(bar: object =>? "bar") } }
When parsing the following JSON:
{ "bar": null }
I would expect decode to not throw, and instead return Foo(bar: nil). What happens instead, is MissingKeyError(key: "bar").
decode
Foo(bar: nil)
MissingKeyError(key: "bar")
Oops, definitely not intended. Should work now though, will bump the version after a double checking a few things.
Thanks!
Thanks for reporting! On cocoa pods now.
Thank you!
I can’t figure out for the life of me why the following does not work:
When parsing the following JSON:
I would expect
decode
to not throw, and instead returnFoo(bar: nil)
. What happens instead, isMissingKeyError(key: "bar")
.