aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/README.md b/README.md
index 1bc88dd..084d27d 100644
--- a/README.md
+++ b/README.md
@@ -374,6 +374,38 @@ with a monad for the response wrapper.
This brings the possibility to `map` and `flatMap` over responses. That way you
could implement e.g. a logging or metric-capturing wrapper.
+## JSON
+
+JSON encoding of bodies and decoding of responses can be handled using
+[Circe](https://circe.github.io/circe/) by the `circe` module. To use
+add the following dependency to your project:
+
+```scala
+"com.softwaremill.sttp" %% "circe" % "0.0.5"
+```
+
+This module adds a method to the request and a function that can be given to
+a request to decode the response to a specific object.
+
+```scala
+import com.softwaremill.sttp._
+import com.softwaremill.sttp.circe._
+
+implicit val handler = HttpURLConnectionSttpHandler
+
+// Assume that there is an implicit circe encoder in scope
+// for the request Payload, and a decoder for the Response
+val requestPayload: Payload = ???
+
+val response: Either[io.circe.Error, Response] =
+ sttp
+ .post(uri"...")
+ .jsonBody(requestPayload)
+ .response(asJson[Response])
+ .send()
+```
+
+
## Request type
All request descriptions have type `RequestT[U, T, S]` (T as in Template).