diff --git a/Sources/JSONAPIMapper/Models/Resource.swift b/Sources/JSONAPIMapper/Models/Resource.swift index b19b249..cf4f0ba 100644 --- a/Sources/JSONAPIMapper/Models/Resource.swift +++ b/Sources/JSONAPIMapper/Models/Resource.swift @@ -22,7 +22,7 @@ public struct Resource: JSONAPICodable { public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - id = try container.decode(String.self, forKey: .id) + id = (try? container.decode(String.self, forKey: .id)) ?? "" type = try container.decode(String.self, forKey: .type) attributes = try container.decodeIfPresent(JSON.self, forKey: .attributes) relationships = try container.decodeIfPresent([String: Relationship].self, forKey: .relationships)