aboutsummaryrefslogtreecommitdiff
path: root/docs/json.rst
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-10-18 16:25:07 +0200
committeradamw <adam@warski.org>2017-10-18 16:25:07 +0200
commita3abbd502783df6df4de98c5dbf0c8eff81cb511 (patch)
tree5457480605483e197ffc658a3f1dcb589a910e99 /docs/json.rst
parent21c4700bbe8cf37d7b9feacc5afdf64357604d8f (diff)
downloadsttp-a3abbd502783df6df4de98c5dbf0c8eff81cb511.tar.gz
sttp-a3abbd502783df6df4de98c5dbf0c8eff81cb511.tar.bz2
sttp-a3abbd502783df6df4de98c5dbf0c8eff81cb511.zip
json4s support
Diffstat (limited to 'docs/json.rst')
-rw-r--r--docs/json.rst27
1 files changed, 26 insertions, 1 deletions
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()
+