Question: Please correct me if I am wrong, but when using Java with say Spring MVC you didn't have to create these extra classes to map your Java class to JSON and JSON to class.

Why do you have to do this in Play with Scala? Is it something to do with Scala?

```
case class Location(lat: Double, long: Double)

implicit val locationWrites: Writes[Location] = (
  (JsPath \ "lat").write[Double] and
  (JsPath \ "long").write[Double]
)(unlift(Location.unapply))

implicit val locationReads: Reads[Location] = (
  (JsPath \ "lat").read[Double] and
  (JsPath \ "long").read[Double]
)(Location.apply _)

```

Answer: 
Since you haven't mentioned which JSON/Spring library integration you meant, I am taking example of JSON via Jackson / Spring integration. I believe it takes advantage of Java Beans field naming convention. This would involve reflection and that happens at run-time.

However, Play's Scala Json library provides compile time safety of all the type in your JSON data. Also it gives you a nice functional syntax `map`, `flatMap`, `orElse` etc. This is a huge advantage.

See this question for more:

<https://softwareengineering.stackexchange.com/questions/228193/json-library-jackson-or-play-framework>
Theoretically it's possible to write function with default implicit parameter like 

```
def toJson[T](x: T)(implicit fmt: Reads[T] = Json.format[T]) = Json.toJson(x)(fmt)

```

But in case of Play Json it will not work because Json.format[T] is a macro and it cannot resolve generic-type symbol T. It can resolve only symbols which directly refers to case classes or any with unapply (see [sources](https://github.com/playframework/playframework/blob/master/framework/src/play-json/src/main/scala/play/api/libs/json/JsMacroImpl.scala "sources"))

On the other hand, it seems to be possible to write a macro which generates same function as i described but instead of Apply( Json.format[T]) uses AST from [JsMacroImpl.macroImpl](https://github.com/playframework/playframework/blob/master/framework/src/play-json/src/main/scala/play/api/libs/json/JsMacroImpl.scala "sources")(c, "format", ...). 

Anyway, it's not a language restriction - it's just not implemented in given library.