Custom naming convention for play-json to map snake_case json to camelCase case classes
Scala
Latest commit 1949ca0 Mar 16, 2016 @tototoshi v1.1.0
Permalink
Failed to load latest commit information.
project Updated sbt version May 28, 2015
src separated Format into Reads and Writes; bumped version May 15, 2015
.gitignore init Jan 19, 2015
LICENSE.txt Added LICENSE.txt Jan 19, 2015
README.md v1.1.0 Mar 16, 2016
build.sbt v1.1.0 Mar 16, 2016

README.md

play-json-naming

Custom naming convention for play-json to map snake_case json to camelCase case classes.

Releases

play-json-naming version Play version
1.1.0 2.5.x
1.0.0 2.4.x
0.2.0 2.3.x

Setup

libraryDependencies += "com.github.tototoshi" %% "play-json-naming" % "1.1.0"

Usage

import com.github.tototoshi.play.json.JsonNaming

case class Name(firstName: String, lastName: String)
case class User(id: Int, nameData: Name)

implicit val nameFormat = JsonNaming.snakecase(Json.format[Name])
implicit val userFormat = JsonNaming.snakecase(Json.format[User])

val jsonString = """{"id":1,"name_data":{"first_name":"Toshiyuki","last_name":"Takahashi"}}"""

Json.parse(jsonString).validate[User]
Json.toJson(User(1, Name("Toshiyuki", "Takahashi")))