Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/ReerJSON/JSONDecoderImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
12 changes: 12 additions & 0 deletions Sources/ReerJSON/Utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down