Please refer to the playground file i attached below. Note that it will work if i define my own decode init function. (can just uncomment {code:java} public init(from decoder: Decoder) throws
The text was updated successfully, but these errors were encountered:
This is correct behavior. It may not be correct to just produce nil here—what if it's "list of users forbidden from accessing my secret data"? Providing custom decoding behavior via init(coder:) is the right way to communicate that to the compiler.
I'm leaving this open because it's a reasonable feature request for some kind of annotation on the property to treat unknown values as nil.
Attachment: Download
Additional Detail from JIRA
md5: 9892ca2b5bd246ad11addcb4eddc868e
Issue Description:
Swift Codable is an awesome feature that i'm using very regularly. But while working with it I found an issue.
So I have a basic struct like this:
And i tried to parse `Parent` with an undefined value from `Children`, i.e:
The issue is instead of receving a Parent instance with `childrean = nil`, it through me a serialization error:
Please refer to the playground file i attached below. Note that it will work if i define my own decode init function. (can just uncomment {code:java} public init(from decoder: Decoder) throws
The text was updated successfully, but these errors were encountered: