JSONRPCKit
JSONRPCKit copied to clipboard
Support for JSONDecoder
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?