diff --git a/KiwiPods/Networking/NetworkManager.swift b/KiwiPods/Networking/NetworkManager.swift index ff85a6b..905d8dd 100644 --- a/KiwiPods/Networking/NetworkManager.swift +++ b/KiwiPods/Networking/NetworkManager.swift @@ -27,7 +27,7 @@ open class NetworkManager: NSObject { case .success(let value): do { decoder.keyDecodingStrategy = .convertFromSnakeCase - if let obj = try ModelClass.objectFrom(json: value, decoder: decoder) as? ModelClass { + if let obj = try ModelClass.objectFrom(json: value, decoder: decoder) { let model = Response.ResponseValue(value: obj, statusCode: response.response?.statusCode) completion(Response.success(model)) } else { diff --git a/KiwiPods/Networking/NetworkModel.swift b/KiwiPods/Networking/NetworkModel.swift index 46d2784..84c6c31 100644 --- a/KiwiPods/Networking/NetworkModel.swift +++ b/KiwiPods/Networking/NetworkModel.swift @@ -78,11 +78,11 @@ public extension ParameterConvertible { } public func toParams()throws -> [String: Any]? { do { - let data = try JSONEncoder().encode(self) - if let dict = try? JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) as? [String: Any] { - return dict - } - return nil + let encoder = JSONEncoder() + encoder.keyEncodingStrategy = .convertToSnakeCase + let data = try encoder.encode(self) + let dict = try JSONSerialization.jsonObject(with: data, options: JSONSerialization.ReadingOptions.mutableContainers) as? [String: Any] + return dict } catch let error { throw error }