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

Support for JSONDecoder #17

Description

@ollitapa

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions