playframework/playframework — pull request #2370 by buster84 (2014-02-13 00:42:00+00:00)
Title: Fix example code on scala json

The example code doesn't work. I guess that the code should be this PR.

`````
scala> import play.api.libs.json._
import play.api.libs.json._
scala> import play.api.libs.functional.syntax._
import play.api.libs.functional.syntax._
scala> case class Person(name: String)
defined class Person
scala> implicit val pwrite: Writes[Person] = __.write[String].contramap( (p: Person) => p.name )
pwrite: play.api.libs.json.Writes[Person] = play.api.libs.json.OWrites$$anon$2@17b63c
scala> pwrite.writes(Person("aaa"))
java.lang.RuntimeException: when empty JsPath, expecting JsObject
at play.api.libs.json.JsPath$.step$1(JsPath.scala:143)
at play.api.libs.json.JsPath$.play$api$libs$json$JsPath$$buildSubPath$1(JsPath.scala:156)
at play.api.libs.json.JsPath$$anonfun$createObj$1.apply(JsPath.scala:161)
at play.api.libs.json.JsPath$$anonfun$createObj$1.apply(JsPath.scala:159)
at scala.collection.IndexedSeqOptimized$class.foldl(IndexedSeqOptimized.scala:51)
at scala.collection.IndexedSeqOptimized$class.foldLeft(IndexedSeqOptimized.scala:60)
at scala.collection.mutable.WrappedArray.foldLeft(WrappedArray.scala:34)
at play.api.libs.json.JsPath$.createObj(JsPath.scala:159)
`````