How to read and write Anorm object with the new JSON API in Play Framework 2.1-RC2?
The Json Macro Inception is not a good choice here, because this case is too complex. It only supports classic case, you cannot map
values for exemple.
In this situation, you need a specific formater
import play.api.libs.json._import play.api.libs.functional.syntax._import anorm._implicit val playerFormat = ( (__ \ "id").formatNullable[Long] and (__ \ "name").formatNullable[String] and (__ \ "group" \ "id").format[Long])((id, name, group) => Player(id.map(Id(_)).getOrElse(NotAssigned), name, group), (p: Player) => (p.playerId.toOption, p.name, p.groupId))
It's a little bit complex, as your requirements are ;)