title: Json Scala object serialization in Play2.2.1 framework
body: <p>So, I've just recently started learning Scala. Sorry for my incompetence in advance.</p>
  
  <p>I tried to look up my answer on stackoverflow. I was able to find several related topics, but I didn't spot my problem.</p>
  
  <p>I'm trying to send a json response based on a Scala object. I have an Action and I'm doing the following:</p>
  
  <pre><code>def oneCredential = Action {
     val cred = Credential("John", "Temp", "5437437")
     Ok(Json.toJson(cred))
  }
  </code></pre>
  
  <p>I've created a case class and appropriate implicit Writes[T] for it</p>
  
  <pre><code>import play.api.libs.json._
  import play.api.libs.functional.syntax._
  import play.api.libs.json.util._
  
  case class Credential(name: String, account: String, password: String)
  
  object  Credential{
    implicit val credentialWrites = (
      (__ \ "name").write[String] and
      (__ \ "account").write[String] and
      (__ \ "password").write[String]
    )(Credential)
  }
  </code></pre>
  
  <p>When I'm trying to run this, I've the following error: "Overloaded method value [apply] cannot be applied to (models.Credential.type)". Also, I tried this </p>
  
  <pre><code>implicit val credentialWrites = (
          (__ \ "name").write[String] and
          (__ \ "account").write[String] and
          (__ \ "password").write[String]
  )(Credential.apply _)
  </code></pre>
  
  <p>Fail. The error: could not find implicit value for parameter fu: play.api.libs.functional.Functor[play.api.libs.json.OWrites]</p>
  
  <p>Then this:</p>
  
  <pre><code>implicit val credentialWrites = (
      (__ \ "name").writes[String] and
      (__ \ "account").writes[String] and
      (__ \ "password").writes[String]
  )(Credential)
  </code></pre>
  
  <p>Another fail: "value writes is not a member of play.api.libs.json.JsPath Note: implicit value credentialWrites is not applicable here because it comes after the application point and it lacks an explicit result type". Right, I understood the first part of an error, but not the second.</p>
  
  <p>Finally I found a shorthand solution:</p>
  
  <pre><code>implicit val credentialWrites = Json.writes[Credential]
  </code></pre>
  
  <p>With this I've got no errors and the code finally worked. I've found the solution on this <a href="http://mandubian.com/2012/11/11/JSON-inception/" rel="nofollow">blog</a>. It's said that the shorthand form is exactly the same as the one with "writes" above. But this "long" form didn't work for me.</p>
  
  <p>Why is shorthand version working, while the long one isn't? Can somebody explain this?</p>
  
  <p>Thank you!</p>
  
  <p>PS Scala version: 2.10.2</p>