Skip to content
playframework2 json extra module. provide convenience functions for define Format, Reads, Writes
Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
generator/src/main/scala
project
src
.gitignore
.travis.yml
README.md
build.sbt
version.sbt

README.md

play-json-extra

Build Status Scala.js scaladoc

motivation and example

I think following way is so verbose.

import play.api.libs.json._
import play.api.libs.functional.syntax._

final case class User(id: Long, name: String)

object User {
  implicit val format: OFormat[User] = (
    (__ \ "id").format[Long] and // I want to omit `Long` and `String`
    (__ \ "name").format[String]
  )(apply _, Function.unlift(unapply))
}

Play provides Json macros. Yes it is useful, but I want to specify Json keys explicitly sometime like argonaut casecodecN

import play.api.libs.json._
import play.jsonext._

final case class User(id: Long, name: String)

object User {
  implicit val format: OFormat[User] =
    CaseClassFormats(apply _, unapply _)("id", "name")
}

latest stable version for play-json 2.7

libraryDependencies += "com.github.xuwei-k" %% "play-json-extra" % "0.6.2"

for scala-js

libraryDependencies += "com.github.xuwei-k" %%% "play-json-extra" % "0.6.2"

snapshot version for play-json 2.7

resolvers += Opts.resolver.sonatypeSnapshots

libraryDependencies += "com.github.xuwei-k" %% "play-json-extra" % "0.6.3-SNAPSHOT"

for scala-js

resolvers += Opts.resolver.sonatypeSnapshots

libraryDependencies += "com.github.xuwei-k" %%% "play-json-extra" % "0.6.3-SNAPSHOT"

old version

You can’t perform that action at this time.