Skip to content
Open
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
6 changes: 3 additions & 3 deletions Sources/BetterCodable/LossyDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension LossyDictionary: Decodable where Key: Decodable, Value: Decodable {
}

private struct AnyDecodableValue: Decodable {}
private struct LossyDecodableValue<Value: Decodable>: Decodable {
private struct LossyDecodableValue: Decodable {
let value: Value

public init(from decoder: Decoder) throws {
Expand All @@ -46,7 +46,7 @@ extension LossyDictionary: Decodable where Key: Decodable, Value: Decodable {

for (key, stringKey) in keys {
do {
let value = try container.decode(LossyDecodableValue<Value>.self, forKey: key).value
let value = try container.decode(LossyDecodableValue.self, forKey: key).value
elements[stringKey as! Key] = value
} catch {
_ = try? container.decode(AnyDecodableValue.self, forKey: key)
Expand All @@ -67,7 +67,7 @@ extension LossyDictionary: Decodable where Key: Decodable, Value: Decodable {
}

do {
let value = try container.decode(LossyDecodableValue<Value>.self, forKey: key).value
let value = try container.decode(LossyDecodableValue.self, forKey: key).value
elements[key.intValue! as! Key] = value
} catch {
_ = try? container.decode(AnyDecodableValue.self, forKey: key)
Expand Down
2 changes: 1 addition & 1 deletion Tests/BetterCodableTests/DefaultCodableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@ class DefaultCodableTests_EnumWithAssociatedValue: XCTestCase {

let data = try JSONEncoder().encode(fixture)
let str = String(data: data, encoding: .utf8)
XCTAssertEqual(str, #"{"value":{"int":4,"fish":"ziz"}}"#)
XCTAssertEqual(str, #"{"value":{"fish":"ziz","int":4}}"#)
}
}