i am new in scala and play framework. Trying to create an sample application by using mongo reactive and play-framework with scala. But i face an issue. When i trying to map my case class, to format for JSON, i am getting an following compile time error in my json formatter:
Multiple markers at this line: No unapply function found
I was also create an simple example before, but that example run successfully. this create a problem. following is my case class code:
case class Video (
var _id: Option[BSONObjectID],
var title: Option[String],
var alias: Option[String],
var categoryIds: Option[List[BSONObjectID]],
var tags: Option[List[String]],
var thumbnailImg: Option[String],
var videoCoverImg: Option[String],
var videoUrl: Option[String],
var isRemote: Option[Boolean],
var userId: Option[BSONObjectID],
var videoEmbedCode: Option[String],
var isPublic: Option[Boolean],
var description: Option[String],
var isPublished: Option[Boolean],
var isRecommended: Option[Boolean],
var access: Option[String],
var uploadedOn: Option[BSONDateTime],
var modifiedOn: Option[BSONDateTime],
var likeCount: Option[Int],
var dislikeCount: Option[Int],
var hitCount: Option[Int],
var metaDesc: Option[String],
var metaKeywords: Option[List[String]],
var author: Option[String]
)
object VideoJsonFormatter {
implicit val videoJsonFormat = Json.format[Video]
}
this implicit val videoJsonFormat = Json.format[Video]
expression create an compile time error :
Multiple markers at this line: No unapply function found
My controller code:
def dashboard = Action.async{
logger.info("In dashboard controller method");
var cursor: Cursor[Video] = videosCollection.find(Json.obj()).cursor[Video];
val videosList : Future[List[Video]] = cursor.collect[List](10, true);
videosList.map { videos => Ok(Json.toJson(videos)) }
}
This var cursor: Cursor[Video] = videosCollection.find(Json.obj()).cursor[Video];
expression generate an compile time error:
No Json deserializer found for type models.Video. Try to implement an implicit Reads or Format for this type.
In case class when we comment some of the properties, this is work successfully. These properties are as follow:
var tags: Option[List[String]]
var userId: Option[BSONObjectID]
var metaKeywords: Option[List[String]]
But i need all properties. how could i resolve this ?