-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
- Add the extension to Encodable to transform an object to a dictionary.
public extension Encodable {
/// Creates a json dictionary from an Encodable Object
var toJsonDictionary: [String: Any] {
let jsonEncoder: JSONEncoder = .default
guard let data = try? jsonEncoder.encode(self) else { return [:] }
let dictionary = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any]
return dictionary ?? [:]
}
}- Add the JSONEncoder to the HTTPClient and a convenient way to use Encodable models for
post/putrequests' bodies
Metadata
Metadata
Assignees
Labels
No labels