@@ -13,8 +13,8 @@ public extension KeyedDecodingContainerProtocol {
1313 /// for the given key.
1414 /// - throws: `DecodingError.valueNotFound` if `self` has a null entry for
1515 /// the given key.
16- func decode( _ type: Dictionary < String , Any > . Type , forKey key: Key ) throws -> Dictionary < String , Any > {
17- let container = try self . nestedContainer ( keyedBy: DictionaryKeys . self, forKey: key)
16+ func decode( _ type: [ String : Any ] . Type, forKey key: Key ) throws -> [ String : Any ] {
17+ let container = try nestedContainer ( keyedBy: DictionaryKeys . self, forKey: key)
1818 return try container. decode ( type)
1919 }
2020
@@ -30,8 +30,8 @@ public extension KeyedDecodingContainerProtocol {
3030 /// for the given key.
3131 /// - throws: `DecodingError.valueNotFound` if `self` has a null entry for
3232 /// the given key.
33- func decode( _ type: Array < Any > . Type , forKey key: Key ) throws -> Array < Any > {
34- var container = try self . nestedUnkeyedContainer ( forKey: key)
33+ func decode( _ type: [ Any ] . Type, forKey key: Key ) throws -> [ Any ] {
34+ var container = try nestedUnkeyedContainer ( forKey: key)
3535 return try container. decode ( type)
3636 }
3737
@@ -48,7 +48,7 @@ public extension KeyedDecodingContainerProtocol {
4848 /// the value is a null value.
4949 /// - throws: `DecodingError.typeMismatch` if the encountered encoded value
5050 /// is not convertible to the requested type.
51- func decodeIfPresent( _ type: Dictionary < String , Any > . Type , forKey key: Key ) throws -> Dictionary < String , Any > ? {
51+ func decodeIfPresent( _ type: [ String : Any ] . Type, forKey key: Key ) throws -> [ String : Any ] ? {
5252 guard contains ( key) else {
5353 return nil
5454 }
@@ -69,7 +69,7 @@ public extension KeyedDecodingContainerProtocol {
6969 /// the value is a null value.
7070 /// - throws: `DecodingError.typeMismatch` if the encountered encoded value
7171 /// is not convertible to the requested type.
72- func decodeIfPresent( _ type: Array < Any > . Type , forKey key: Key ) throws -> Array < Any > ? {
72+ func decodeIfPresent( _ type: [ Any ] . Type, forKey key: Key ) throws -> [ Any ] ? {
7373 guard contains ( key) else {
7474 return nil
7575 }
@@ -86,36 +86,36 @@ public extension KeyedDecodingContainerProtocol where Key == DictionaryKeys {
8686 /// and convertible to the requested type.
8787 /// - throws: `DecodingError.typeMismatch` if the encountered encoded value
8888 /// is not convertible to the requested type.
89- func decode( _ type: Dictionary < String , Any > . Type ) throws -> Dictionary < String , Any > {
89+ func decode( _ type: [ String : Any ] . Type) throws -> [ String : Any ] {
9090 var dictionary : [ String : Any ] = [ : ]
91-
91+
9292 for key in allKeys {
9393 if let boolValue = try ? decode ( Bool . self, forKey: key) {
9494 dictionary [ key. stringValue] = boolValue
95-
95+
9696 } else if let intValue = try ? decode ( Int . self, forKey: key) {
9797 dictionary [ key. stringValue] = intValue
98-
98+
9999 } else if let doubleValue = try ? decode ( Double . self, forKey: key) {
100100 dictionary [ key. stringValue] = doubleValue
101-
101+
102102 } else if let stringValue = try ? decode ( String . self, forKey: key) {
103103 dictionary [ key. stringValue] = stringValue
104-
105- } else if let nestedDictionary = try ? decode ( Dictionary < String , Any > . self, forKey: key) {
104+
105+ } else if let nestedDictionary = try ? decode ( [ String : Any ] . self, forKey: key) {
106106 dictionary [ key. stringValue] = nestedDictionary
107-
108- } else if let nestedArray = try ? decode ( Array < Any> . self , forKey: key) {
107+
108+ } else if let nestedArray = try ? decode ( [ Any ] . self, forKey: key) {
109109 dictionary [ key. stringValue] = nestedArray
110-
110+
111111 } else if try decodeNil ( forKey: key) {
112112 dictionary [ key. stringValue] = NSNull ( )
113113 } else {
114114 let context = DecodingError . Context ( codingPath: [ key] , debugDescription: " Invalid Decoding Value " )
115115 throw DecodingError . typeMismatch ( type, context)
116116 }
117117 }
118-
118+
119119 return dictionary
120120 }
121121}
0 commit comments