@@ -129,6 +129,12 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
129
129
is Primitive . UInt32 . Type ,
130
130
is Primitive . UInt64 . Type ,
131
131
is Primitive . Empty . Type : return try value. unwrap { throw error }
132
+ // Special Cases
133
+ // case is Date.Type: return unwrapDate() as! T
134
+ // case is Data.Type: return unwrapData() as! T
135
+ // case is URL.Type: return unwrapURL() as! T
136
+ // case is Decimal.Type: return unwrapDecimal() as! T
137
+ // case is _JSONStringDictionaryDecodableMarker.Type: return unwrapDictionary(as: T.self) as! T
132
138
// Decodable Types
133
139
default : return try T ( from: self )
134
140
}
@@ -150,6 +156,7 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
150
156
return floatingPoint
151
157
}
152
158
159
+ // may want to support both strict numeric checks as well as loose numeric checks (used below).
153
160
switch representation {
154
161
case . float64( let number) : return try validate ( T ( number) , originalValue: number)
155
162
case . float32( let number) : return try validate ( T ( number) , originalValue: number)
@@ -164,6 +171,17 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
164
171
case . uint32( let number) : return try validate ( T ( number) , originalValue: number)
165
172
case . uint64( let number) : return try validate ( T ( number) , originalValue: number)
166
173
174
+ // case .string(let string):
175
+ // if case .convertFromString(let posInfString, let negInfString, let nanString) = self.options.nonConformingFloatDecodingStrategy {
176
+ // if string == posInfString {
177
+ // return T.infinity
178
+ // } else if string == negInfString {
179
+ // return -T.infinity
180
+ // } else if string == nanString {
181
+ // return T.nan
182
+ // }
183
+ // }
184
+ //
167
185
case . string,
168
186
. bool,
169
187
. keyed,
@@ -190,6 +208,7 @@ extension DynamicCodableDecoder.Decoder: Swift.Decoder {
190
208
return fixedWidthInteger
191
209
}
192
210
211
+ // may want to support both strict numeric checks as well as loose numeric checks (used below).
193
212
switch representation {
194
213
case . int( let number) : return try validate ( T ( exactly: number) , originalValue: number)
195
214
case . int8( let number) : return try validate ( T ( exactly: number) , originalValue: number)
@@ -231,6 +250,39 @@ extension DynamicCodableDecoder.Decoder {
231
250
232
251
var codingPath : [ CodingKey ] { decoder. codingPath }
233
252
253
+ // init(
254
+ // decoder: DynamicCodableDecoder.Decoder,
255
+ // codingPath: [CodingKey],
256
+ // representation: [DynamicCodable.Key : DynamicCodable]
257
+ // ) {
258
+ // self.decoder = decoder
259
+ // self.codingPath = codingPath
260
+ //
261
+ //// switch impl.options.keyDecodingStrategy {
262
+ //// case .useDefaultKeys:
263
+ //// self.dictionary = dictionary
264
+ //// case .convertFromSnakeCase:
265
+ //// // Convert the snake case keys in the container to camel case.
266
+ //// // If we hit a duplicate key after conversion, then we'll use the first one we saw.
267
+ //// // Effectively an undefined behavior with JSON dictionaries.
268
+ //// var converted = [String: JSONValue]()
269
+ //// converted.reserveCapacity(dictionary.count)
270
+ //// dictionary.forEach { (key, value) in
271
+ //// converted[JSONDecoder.KeyDecodingStrategy._convertFromSnakeCase(key)] = value
272
+ //// }
273
+ //// self.dictionary = converted
274
+ //// case .custom(let converter):
275
+ //// var converted = [String: JSONValue]()
276
+ //// converted.reserveCapacity(dictionary.count)
277
+ //// dictionary.forEach { (key, value) in
278
+ //// var pathForKey = codingPath
279
+ //// pathForKey.append(_JSONKey(stringValue: key)!)
280
+ //// converted[converter(pathForKey).stringValue] = value
281
+ //// }
282
+ //// self.dictionary = converted
283
+ //// }
284
+ // }
285
+
234
286
var allKeys : [ Key ] {
235
287
representation. keys. compactMap { dynamicKey in
236
288
switch dynamicKey {
0 commit comments