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
SR-9023 Decoding a JSON Dictionary with a UUID key either doesn't work, or shows the wrong error message
Issue Description:
If you are going to decode a string to date with the .formatted date decoding strategy as dictionary key you get a type mismatch error about an expected array:
typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "bar", intValue: nil)], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
This is essentially SR-9023 but with Date instead of UUID. The issue here is that Dictionary doesn't know anything about encoding strategies, and has no idea that Date will encode as a string at the end of the day. All it knows how to encode are dictionaries keyed by String or Int, and all other types fall into encoding and decoding as an unkeyed container. It tries to decode from an unkeyed container, but fails since the JSON actually contains a dictionary (a keyed container).
There's a bit more info in SR-9023 that explains what's going on here.
Environment
MacPro 5.1 16 GB RAM
macOS 10.13.6
Xcode 10.1 (10B61)
Additional Detail from JIRA
md5: e77591025a62597c54cf4a4375ecad36
duplicates:
Issue Description:
If you are going to decode a string to date with the .formatted date decoding strategy as dictionary key you get a type mismatch error about an expected array:
typeMismatch(Swift.Array<Any>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "bar", intValue: nil)], debugDescription: "Expected to decode Array<Any> but found a dictionary instead.", underlyingError: nil))
Code:
The text was updated successfully, but these errors were encountered: