score:4
Accepted answer
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 ;)
Source: stackoverflow.com
Related Query
- How to read and write Anorm object with the new JSON API in Play Framework 2.1-RC2?
- How do you read the HTML content of an Atom feed with Scala and Play framework 2.0?
- Play: How to remove the fields without value from JSON and create a new JSON with them
- How to create an instance of a model with the ebean framework and scala in Play 2.2
- How to write the <?xml> tag using scala.xml and Play Framework
- How to read json array in scala using the Play framework
- How to expose a Restful Endpoint in Play Framework for uploading a File and Posting a JSON at the same time?
- How to organise the entity model for play framework 2 when working with anorm
- Play Framework 2.4.1 One form with two buttons. Which button was pressed? And how do I get the input data?
- How to synchronize Play framework 2 with MongoDB and the steps to be followed
- How to use IntelliJ with Play Framework and Scala
- How to implement implicit Json Writes of embedded object in Play Framework 2.x
- How to Retrieve the Primary Key When Saving a New Object in Anorm
- Dependency injection with abstract class and object in Play Framework 2.5
- How to respond with a pretty-printed JSON object using play framework?
- Dynamic SQL Parameters with Anorm and Scala Play Framework
- How do I write a JSON Format for an object in the Java library that doesn't have an apply method?
- How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
- How to write a Play JSON writes converter for a case class with a single nullable member
- Play framework JSON reads: How to read either String or Int?
- How to show images using Play framework and Scala in the view page
- How to set up play framework ApplicationLoader and Macwire to work with custom routes?
- How i can integrate Apache Spark with the Play Framework to display predictions in real time?
- How can I write and read an empty case class with play-json?
- Why I get "Application does not take parameters" using JSON Read with Play framework 2.3?
- How to use the Play Framework with Google App Engine with locally installed Java 7?
- Play Scala: How to access multiple databases with anorm and Magic[T]
- Play framework 2 : How to pass object between routes, views, and controller?
- Play framework JSON transformers, how to work with recursive paths (jsPath)?
- Serialize objects with Play Scala api and Json
More Query from same tag
- for-comprehension, guard and RandomAccessFile.readLine
- Reactivemongo leaking connections during Play hot-reload
- Is it possible to access anonymous outer classes?
- Scala JavaScript Routing Play Framework
- Scala parser combinators parsing xml?
- rename column name of spark data frame based on csv
- How to compose a Matcher[Iterable[A]] from a Matcher[A] with specs testing framework
- How do I replace part of json sub tree in lift framework
- Parsing RTF in Tika yields only Newline Chars
- Parse a JSON gives JsResultException
- mongodb ORMs without full schema?
- Porting a Maven Java project that uses JavaCC to Scala
- How do you implement throttling of calls to method that supports async callback
- Answer ask in AkkaTestKit
- Spark caching in combination with multiple sources and actions
- What does split() function do in spark
- Bazel error: type 'java_common' has no method create_provider()
- Convert dataframe to hash-map using Spark Scala
- Subtle differences between val and parameterless def
- Reshape spark data frame of key-value pairs with keys as new columns
- Scala not handling non-explicitly typed closures for ':' functions
- Spark Java - Cannot get the correct classtag for java.lang.String
- Combining/joining rows of IDs in spark
- Why one Kafka streams block the other one from getting started?
- select and use appropriate decoder as decoder for new item while preserving error accumulation
- Multiple Fields in For Expression
- How to put the range of dates in a specific format?
- bad symbolic reference on SQLContext.class in Eclipse Luna scala IDE
- How to schedule random messages in Akka? (Message reference is always the same)
- error: polymorphic expression with default arguments