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
In this case the error message is `Invalid URL string.` which is correct because it's an empty string so its not a valid URL, but the `homepageUrl` is optional, so it should produce a nil value instead of failing.
If the `MyStruct` is using `CodingKeys` (uncomment that part of the code), then its working fine with empty string in dictionary.
I think its a swift bug because: If `keyDecodingStrategy` is `convertFromSnakeCase` then it should produce nil without using `CodingKeys`.
The text was updated successfully, but these errors were encountered:
I don't think the empty string is considered the same as a null value, and Optional does not mean "ignore errors" for Codable's purposes. cc bendjones (JIRA User)
yeah thats true, but the weird thing is that if the struct using CodingKeys the behaviour is not the same. I don't think that the CodingKeys usage should modify the result if the keyDecodingStrategy is convertFromSnakeCase
I guess the reason it's "working fine with empty string in dictionary" when you add CodingKeys is because the decoder then no longer matches "homepage_url" key to your homepageUrl property. That can be validated by putting a valid URL string in your json and your homepageUrl would still be nil. With the decoder set to .convertFromSnakeCase snake-case keys are converted to camel-case keys, and that means that the manual snake-case mapping you do in your CodingKeys results in a mismatch and hence homepageUrl will never be set. Keeping the CodingKeys and removing the .convertFromSnakeCase you match again, and the `Invalid URL String` error would return.
Environment
Swift 4.2
Xcode 10.1 (10B61)
Additional Detail from JIRA
md5: d568d9a734aa22a2960bae6ad83bfe20
Issue Description:
In this case the error message is `Invalid URL string.` which is correct because it's an empty string so its not a valid URL, but the `homepageUrl` is optional, so it should produce a nil value instead of failing.
If the `MyStruct` is using `CodingKeys` (uncomment that part of the code), then its working fine with empty string in dictionary.
I think its a swift bug because: If `keyDecodingStrategy` is `convertFromSnakeCase` then it should produce nil without using `CodingKeys`.
The text was updated successfully, but these errors were encountered: