mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-09 22:36:01 +05:45
Fix RC Codable to handle arrays and dictionaries from plist defaults (#10046)
This commit is contained in:
1 parent
cbaa7ce706
commit
bc2bc6b9f2
9 files changed
+118
-5
No files matched your search
+19
-2
@@ -1252,8 +1252,11 @@ fileprivate class __JSONDecoder : Decoder {
|
||||
debugDescription: "Cannot get keyed decoding container -- found null value instead."))
|
||||
}
|
||||
var topContainer : [String : Any]
|
||||
if let rcValue = self.storage.topContainer as? FirebaseRemoteConfigValueDecoding,
|
||||
let top = rcValue.jsonValue() {
|
||||
if let rcValue = self.storage.topContainer as? FirebaseRemoteConfigValueDecoding {
|
||||
guard let top = rcValue.dictionaryValue() else {
|
||||
throw DecodingError._typeMismatch(at: self.codingPath, expectation: [String : Any].self,
|
||||
reality: rcValue)
|
||||
}
|
||||
topContainer = top
|
||||
} else {
|
||||
guard let top = self.storage.topContainer as? [String : Any] else {
|
||||
@@ -1273,6 +1276,13 @@ fileprivate class __JSONDecoder : Decoder {
|
||||
debugDescription: "Cannot get unkeyed decoding container -- found null value instead."))
|
||||
}
|
||||
|
||||
if let rcValue = self.storage.topContainer as? FirebaseRemoteConfigValueDecoding {
|
||||
guard let arrayValue = rcValue.arrayValue() else {
|
||||
throw DecodingError._typeMismatch(at: self.codingPath, expectation: [Any].self, reality: rcValue)
|
||||
}
|
||||
return _JSONUnkeyedDecodingContainer(referencing: self, wrapping: arrayValue )
|
||||
}
|
||||
|
||||
guard let topContainer = self.storage.topContainer as? [Any] else {
|
||||
throw DecodingError._typeMismatch(at: self.codingPath, expectation: [Any].self, reality: self.storage.topContainer)
|
||||
}
|
||||
@@ -2468,6 +2478,13 @@ extension __JSONDecoder {
|
||||
fileprivate func unbox<T>(_ value: Any, as type: _JSONStringDictionaryDecodableMarker.Type) throws -> T? {
|
||||
guard !(value is NSNull) else { return nil }
|
||||
|
||||
if let rcValue = value as? FirebaseRemoteConfigValueDecoding {
|
||||
guard let dictionaryValue = rcValue.dictionaryValue() else {
|
||||
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: rcValue)
|
||||
}
|
||||
return dictionaryValue as? T
|
||||
}
|
||||
|
||||
var result = [String : Any]()
|
||||
guard let dict = value as? NSDictionary else {
|
||||
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
|
||||
|
||||
Reference in new issue
Block a user