-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS: Expand AnyType to handle deeply nested AnyType for beacon encoding #519
Conversation
@@ -154,6 +167,12 @@ struct CustomEncodable: CodingKey { | |||
self.stringValue = key | |||
if let encodable = encodable as? Encodable { | |||
self.data = encodable | |||
} else if | |||
let encodable, | |||
let data = try? JSONSerialization.data(withJSONObject: encodable, options: .fragmentsAllowed), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.fragmentsAllowed
lets us encode String
here as a top level type in JSON (normally JSON would need to be []
or {}
as the top level type), as we dont know what the value type will be
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #519 +/- ##
==========================================
+ Coverage 91.89% 91.91% +0.01%
==========================================
Files 341 341
Lines 27232 27311 +79
Branches 1944 1944
==========================================
+ Hits 25026 25103 +77
- Misses 2192 2194 +2
Partials 14 14
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
AnyType
decoded as a part of the asset tree did not haveAnyTypeDecodingContext
to allow for[String: Any]
decoding, that context is now added inBaseRegistry
when decoding the asset treeIncluding complex metadata for beacons would not reencode when passing the beacon from Swift to JSC in all scenarios.
In this scenario, this metadata would be decoded by the ActionAsset, which includes
AnyType
for the beacon metadata. When sending this decoded type throughBeaconContext.beacon
, the encoding was failing for the nested keys, as the entirebeacon
key would be decoded asAnyType
with.anyDictionary([String: Any])
. Encoding theAny
values failed.CustomEncodable
did not work againstAny
, so instead, I decodeAny
asAnyType
which is then encodable, and can be used as the backing type for encodingChange Type (required)
Indicate the type of change your pull request is:
patch
minor
major
Does your PR have any documentation updates?
Version
Published prerelease version:
0.9.2-next.0
Changelog
🐛 Bug Fix
Authors: 1