jsonscalarestscala-dispatch

JSON Data Conversion for Rest Calls in Scala


I have worked on Rest development with Spring. Spring library takes care of JSON data conversion in a request body as well as in a response. I am wondering any good approach for Dispatch, a Scala Rest library, that is to convert a case class to a JSON data for a request body and convert a response data to a case class.

Update:

After some study, I think the toString method can be used to convert a case class to a JSON data. There will be some more code if a case class has some Option fields.


Solution

  • In combination of Dispatch I am using json4s to serialise / deserialise my json bodies. You can have a look at it here : http://json4s.org/. You can also consider using spray-json, circe, Argaunot, it's up to you !!