Automatically decode from snake case

This commit is contained in:
Victor Bodinaud
2024-05-17 17:35:29 +02:00
parent 5602a76477
commit 985853100b

View File

@@ -127,7 +127,10 @@ public struct Hermes {
} }
} }
guard let result = try? JSONDecoder().decode(resource.modelType, from: data) else { let decoder = JSONDecoder()
decoder.keyDecodingStrategy = .convertFromSnakeCase
guard let result = try? decoder.decode(resource.modelType, from: data) else {
throw NetworkError.decodingError throw NetworkError.decodingError
} }