title: ReactiveMongo mapping from ObjectId to case class BSONObjectID
body: <p>i am new in Scala and Play, i am trying to map Scala <code>BSONObjectID</code> to mongo <code>ObjectId</code>. I got many samples from internet, but still stuck in one compile time error. Following is code of my Case Class: </p>
  
  <pre><code>case class UserDetail(
   val _id: Option[BSONObjectID],
   val name: String,
   val age: Double,
   var created: Option[Long]
  )  
  
  object UserDetail{
   implicit val userDetailReads: Reads[UserDetail] = (
   (JsPath \ "_id").readNullable[BSONObjectID] and
   (JsPath \ "name").read[String] and
   (JsPath \ "age").read[Double] and
   (JsPath \ "created").readNullable[Long]
  )(UserDetail.apply _)
  
  implicit val userDetailWrites: Writes[UserDetail] = (
  (JsPath \ "_id").writeNullable[BSONObjectID]and
  (JsPath \ "name").write[String] and
  (JsPath \ "age").write[Double] and
  (JsPath \ "created").writeNullable[Long]
  )(unlift { UserDetail.unapply })}
  </code></pre>
  
  <p>This <code>(JsPath \ "_id").readNullable[BSONObjectID]</code> generate compile time error as below: </p>
  
  <pre><code>not enough arguments for method readNullable: (implicit r: play.api.libs.json.Reads[reactivemongo.bson.BSONObjectID])play.api.libs.json.Reads[Option[reactivemongo.bson.BSONObjectID]]. Unspecified value parameter r.
  not enough arguments for method readNullable: (implicit r: play.api.libs.json.Reads[reactivemongo.bson.BSONObjectID])play.api.libs.json.Reads[Option[reactivemongo.bson.BSONObjectID]]. Unspecified value parameter r.
  </code></pre>
  
  <p>This <code>(JsPath \ "_id").writeNullable[BSONObjectID]</code> also generate same error. </p>
  
  <p>I want to format my json request. So i am using custom formatter as below: </p>
  
  <pre><code>object BSONObjectIDFormat extends Format[BSONObjectID]{
  
   def writes(objectId: BSONObjectID): JsValue = JsString(objectId.toString())
  
   def reads(json: JsValue): JsResult[BSONObjectID] = json match {
    case JsString(x) =&gt; {
    val maybeOID: Try[BSONObjectID] = BSONObjectID.parse(x)
    if(maybeOID.isSuccess) JsSuccess(maybeOID.get) else {
      JsError("Expected BSONObjectID as JsString")
    }
  }
  case _ =&gt; JsError("Expected BSONObjectID as JsString")
  }}
  </code></pre>
  
  <p>My Json request as below: </p>
  
  <pre><code>{
  "_id":{"$oid":"54fd4b7084071e6a6ab13cee"},
  "name" : "Akka",
  "age" : 30,
  "created" : 1425886070013
  }
  </code></pre>
  
  <p>When i send the JSON request, i got following error: </p>
  
  <pre><code>[error] D:\play_projects\scala_play_sample\app\models\UserDetail.scala:35: No Js
  on deserializer found for type reactivemongo.bson.BSONObjectID. Try to implement
  an implicit Reads or Format for this type.
  [error]     (JsPath \ "_id").readNullable[BSONObjectID] and
  [error]                                  ^
  [error] D:\play_projects\scala_play_sample\app\models\UserDetail.scala:42: No Js
  on serializer found for type reactivemongo.bson.BSONObjectID. Try to implement a
  n implicit Writes or Format for this type.
  [error]     (JsPath \ "_id").writeNullable[BSONObjectID]and
  </code></pre>