I have two tracks.
implicit val readObjectIdFormat = new Reads[ObjectId] { def reads(jv: JsValue): JsResult[ObjectId] = { JsSuccess(new ObjectId(jv.as[String])) } } implicit val visitorFormat = ( (__ \ "_id").formatOpt[ObjectId] and (__ \ "visitorId").format[String] and (__ \ "referralUrl").formatOpt[String] and (__ \ "ipAddress").formatOpt[String] and (__ \ "promotionId").format[String])(Visitor)
Although readObjectIdFormat is determined at compile time, it continues to complain about "(__ \" _id "). FormatOpt [ObjectId]" line
There is no Json formatting for type org.bson.types.ObjectId. Try to implement an implicit format for this type.
: playback 2.1-RC2, Scala 2.10
Any idea why it doesn't recognize readObjectIdFormat?
source share