diff --git a/Sources/ReerJSON/JSONDecoderImpl.swift b/Sources/ReerJSON/JSONDecoderImpl.swift index 957c3e0..f90b99d 100644 --- a/Sources/ReerJSON/JSONDecoderImpl.swift +++ b/Sources/ReerJSON/JSONDecoderImpl.swift @@ -168,7 +168,7 @@ final class JSONDecoderImpl: Decoder { if type == Decimal.self { return try unboxDecimal(from: value, for: codingPathNode, additionalKey) as! T } - if let dictType = type as? StringDecodableDictionary.Type { + if !options.keyDecodingStrategy.isDefault, let dictType = type as? StringDecodableDictionary.Type { return try unboxDictionary(from: value, as: dictType, for: codingPathNode, additionalKey) } diff --git a/Sources/ReerJSON/Utilities.swift b/Sources/ReerJSON/Utilities.swift index 189a21a..7553bea 100644 --- a/Sources/ReerJSON/Utilities.swift +++ b/Sources/ReerJSON/Utilities.swift @@ -127,6 +127,18 @@ extension Dictionary : StringDecodableDictionary where Key == String, Value: Dec static var elementType: Decodable.Type { return Value.self } } +extension JSONDecoder.KeyDecodingStrategy { + @inline(__always) + var isDefault: Bool { + switch self { + case .useDefaultKeys: + return true + default: + return false + } + } +} + // This is a workaround for the lack of a "set value only if absent" function for Dictionary. extension Optional { mutating func _setIfNil(to value: Wrapped) {