Created AnyDecodable#1568
Merged
Merged
Conversation
NachoSoto
commented
May 11, 2022
Contributor
Author
There was a problem hiding this comment.
This allows decoding all the data in JSON into [String: Any], which normally wouldn't be Decodable.
This will be used to decode the entire data in JSON for the new implementation of `RawDataContainer` in #1496.
taquitos
approved these changes
May 16, 2022
| self = .null | ||
| } else if let value = try? container.decode(String.self) { | ||
| self = .string(value) | ||
| } else if let value = try? container.decode(Int.self) { |
Contributor
There was a problem hiding this comment.
I shouldn't be surprised, yet I am- if you pass in 2.5 it won't try to decode as an Int, it will work as a Double. That's neat.
NachoSoto
added a commit
that referenced
this pull request
May 24, 2022
Follow up to #1496. Depends on #1567 and #1568. The solution implemented in #1496 was very simple, but [as pointed out by @joshdholtz](#1496 (comment)), it was only encoding the data that was formally decoded by the `struct`s. We had no test coverage for this, so it went unnoticed. The new solution adds a new field: ```swift @IgnoreEncodable var rawData: [String: Any] ``` Which, together with a new helper method `decodeRawData()`, allows storing all the data to be used by `CustomerInfo`'s `RawDataContainer` implementation. Unfortunately, despite many attempts, I realized that this can't be abstracted into a property wrapper, because a `KeyedDecodingContainer` can't access the parent `Decoder`. That's why the `CustomerInfoResponse` and `CustomerInfoResponse.Entitlement` must manually call this method.
NachoSoto
added a commit
that referenced
this pull request
May 24, 2022
…1565) Follow up to #1496. Depends on ~~#1567, #1568, #1604~~. The solution implemented in #1496 was very simple, but [as pointed out by @joshdholtz](#1496 (comment)), it was only encoding the data that was formally decoded by the `struct`s. We had no test coverage for this, so it went unnoticed. The new solution adds a new field: ```swift @IgnoreEncodable @IgnoreHashable var rawData: [String: Any] ``` Which, together with a new helper method `decodeRawData()`, allows storing all the data to be used by `CustomerInfo`'s `RawDataContainer` implementation. Unfortunately, despite many attempts, I realized that this can't be abstracted into a property wrapper, because a `KeyedDecodingContainer` can't access the parent `Decoder`. That's why the `CustomerInfoResponse` and `CustomerInfoResponse.Entitlement` must manually call this method.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will be used to decode the entire data in JSON for the new implementation of
RawDataContainerin #1496.