Skip to content

Conversation

@adam-fowler
Copy link
Contributor

On Darwin when you call superDecoder on the JSONDecoder keyed container and there is no associated value for the key passed in, it returns a new decoder that returns empty containers. On Linux it would throw a DecodingError.keyNotFound error.

This PR resolves this discrepancy by catching the DecodingError.keyNotFound error and returning a decoder that references a JSONValue.null.

The PR also adds a new test test_notFoundSuperDecoder to verify this fix.

This resolves #3169

* Don't throw DecodingError if superDecoder doesn't exist

* Add decoderForKeyNoThrow

* Improve JSONDecoder error handling

When trying to created a keyed container or unkeyed containter from
a null value throw a `DecodingError.valueNotFound` error instead of
a `typeMismatch` error.  This is more inline with Darwin.
@tomerd
Copy link

tomerd commented Sep 9, 2022

@parkera

@parkera
Copy link
Contributor

parkera commented Sep 12, 2022

@swift-ci test

@adam-fowler
Copy link
Contributor Author

Is there any reason this hasn't been merged.

@parkera parkera merged commit 3f3537a into swiftlang:release/5.7 Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants