Arrays are not supported. Make it a list, a seq, nearly any other type of collection, and your document will serialize and deserialize correctly.

Make a player case class with all the possible fields and use default arguments to cover all the cases.

If there are too many different cases to cover, that's when things get really ugly. You are essentially trying to deserialize data that has no expected structure as ... what, exactly? I haven't added Map[String, Any] support to mainstream Salat although there is an outstanding pull request.


You probably have to use some custom serializer here, I assume you have a handle to the parent object - lets call that injury

 val playerRefs = injury.get("palyers")
 var obj = MongoDBObject("list" -> playerRefs )[MongoDBList]("list").toList.foreach {
   value =>
        val playerDef = value.asInstanceOf[BasicDBObject]
        // Access values from player -
        val name = playerDef.get("name")asInstanceOf[String]
        // Build your case class 

Related Query

More Query from same tag