Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Support for JSONDecoder #17

Open
ollitapa opened this issue Apr 3, 2018 · 0 comments
Open

Support for JSONDecoder #17

ollitapa opened this issue Apr 3, 2018 · 0 comments

Comments

@ollitapa
Copy link

ollitapa commented Apr 3, 2018

Now that Swift 4 has quite nice JSONDecoder functionality, could we support that using passing instances of Data or Decoder instead of the JSON Dictionary?

Currently the Request gets Any ( [String: Any] ) passed to

func response(from resultObject: Any) throws -> Response 

which in turn needs to be encoded to Data using

let resultData = try JSONSerialization.data(withJSONObject: resultObject, options: [])
let decoder = JSONDecoder()

return try decoder.decode(Response.self, from: resultData)

Could we skip this by passing around Data or Decoder?

like

func response(from resultObject: Data) throws -> Response 

or

func response(from decoder: Decoder) throws -> Response 

Or is this something that limits the generic use of the framework?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant