https://github.com/http4s/http4s-play-json
Play JSON codecs for http4s
https://github.com/http4s/http4s-play-json
Last synced: 5 months ago
JSON representation
Play JSON codecs for http4s
- Host: GitHub
- URL: https://github.com/http4s/http4s-play-json
- Owner: http4s
- License: apache-2.0
- Created: 2022-05-02T14:59:41.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-06-08T12:12:01.000Z (8 months ago)
- Last Synced: 2025-06-08T13:20:45.627Z (8 months ago)
- Language: Scala
- Homepage:
- Size: 185 KB
- Stars: 3
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http4s-play-json [](https://github.com/http4s/http4s-play-json/actions/workflows/ci.yml) [](https://img.shields.io/maven-central/v/org.http4s/http4s-play-json_2.13?versionPrefix=0.23) 
Provides `EntityEncoder` and `EntityDecoder` support for [play-json](https://github.com/playframework/play-json) JSON library.
## SBT Setup
```sbt
libraryDependencies += "org.http4s" %% "http4s-play-json" % "0.23.13"
```
## Usage
```scala
import org.http4s.play._
import play.api.libs.json._
// Lets fetch some JSON from a website and parse it
// into a case class that has a play-json `Format` defined (Reads/Writes)
// Assumes that https://mydomain.invalid/sample.json responds:
// { "hello": "world" }
case class SampleResponse(hello: String)
object SampleResponse {
// Play-json formatter for { "hello": "world" }
implicit val format: Format[SampleResponse] = Json.format
}
// Fetch with an http4s client
val client: Client[F] = ???
val target = Uri.uri("http://mydomain.invalid/sample.json")
// The response will be deserialised to a `SampleResponse`
// using the implicit play-json `Format`
val response: F[Sample] = httpClient.expect[SampleResponse](target)
```
## Community
The [Typelevel Discord](https://discord.gg/XF3CXcMzqD) has an #http4s channel. Please join us!
## See also
Other JSON compatibility modules for http4s include: http4s-circe (in the core repo) and [http4s-fabric](https://github.com/http4s/http4s-fabric).