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
12 changes: 11 additions & 1 deletion Sources/ZippyJSON/ZippyJSONDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,24 @@ final private class __JSONDecoder: Decoder {
debugDescription: "Invalid URL string."))
}
return url
} else if let stringKeyedDictType = type as? DictionaryWithoutKeyConversion.Type {
} else if keyDecodingStrategy.isNotDefault, let stringKeyedDictType = type as? DictionaryWithoutKeyConversion.Type {
return try unbox(value, as: stringKeyedDictType, key: nil)
} else {
return try type.init(from: self)
}
}
}

extension ZippyJSONDecoder.KeyDecodingStrategy {
@inline(__always)
var isNotDefault: Bool {
switch self {
case .useDefaultKeys: false
default: true
}
}
}

extension __JSONDecoder {
// UnboxBegin
@inline(__always) fileprivate func unbox(_ value: Value, as type: UInt8.Type, key: CodingKey?) throws -> UInt8 {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ZippyJSONTests/ZippyJSONDecoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class ZippyJSONTests: XCTestCase {
let a: [String: String]
}
// testRoundTrip(of: Aa.self, json: #"{"a": {}}"#)
_testFailure(of: Aa.self, json: #"{"a": 2}"#)
_testFailure(of: Aa.self, json: #"{"a": 2}"#, relaxedErrorCheck: true)
}

func testNilAdvance() {
Expand Down