From a3abbd502783df6df4de98c5dbf0c8eff81cb511 Mon Sep 17 00:00:00 2001 From: adamw Date: Wed, 18 Oct 2017 16:25:07 +0200 Subject: json4s support --- docs/json.rst | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'docs/json.rst') diff --git a/docs/json.rst b/docs/json.rst index 032c120..0d3a8ce 100644 --- a/docs/json.rst +++ b/docs/json.rst @@ -30,4 +30,29 @@ This module adds a method to the request and a function that can be given to a r .response(asJson[Response]) .send() - +Json4s +------ + +To encode and decode json using json4s-native, add the following dependency to your project:: + + "com.softwaremill.sttp" %% "json4s" % "0.0.20" + +Using this module it is possible to set request bodies and read response bodies as case classes, using the implicitly available ``org.json4s.Formats`` (which defaults to ``org.json4s.DefaultFormats``). + +Usage example:: + + import com.softwaremill.sttp._ + import com.softwaremill.sttp.json4s._ + + implicit val backend = HttpURLConnectionBackend() + + case class Payload(...) + val requestPayload: Payload = Payload(...) + + val response: Response[Payload] = + sttp + .post(uri"...") + .body(requestPayload) + .response(asJson[Response]) + .send() + -- cgit v1.2.3