Anviking / Decodable

[Probably deprecated] Swift 2/3 JSON unmarshalling done (more) right
MIT License
1.04k stars 73 forks source link

Does `=>?` actually work as intended? #70

Closed irace closed 8 years ago

irace commented 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").

Anviking commented 8 years ago

Oops, definitely not intended. Should work now though, will bump the version after a double checking a few things.

irace commented 8 years ago

Thanks!

Anviking commented 8 years ago

Thanks for reporting! On cocoa pods now.

irace commented 8 years ago

Thank you!