I am working on a small project try to get a Scala/Play backend working. I am trying to have it return and also process JSON on the web service side. I cannot seem to figure out how to get the JSON marshalling and unmarshalling to work. Could someone help me with this issue? I am using Play 2.1 and Scala 2.10. The error that I get is "overriding method reads in trait Reads of type (json: play.api.libs.json.JsValue)play.api.libs.json.JsResult[models.Address]; method reads has incompatible type"
Edited. Someone else gave me the solution. For read you must use JsSuccess, not JsResult.
case class Address(id: Long, name: String) object Address { implicit object AddressFormat extends Format[Address] { def reads(json: JsValue):Address = JsSuccess(Address( (json \ "id").as[Long], (json \ "name").as[String] )) def writes(address: Address): JsValue = JsObject(Seq( "id" -> JsNumber(address.id), "name" -> JsString(address.name) )) } }