scalacase-classcasbahsalat

How to use a case class to deserialize an array of json objects to List[Map[String,String]]


I am having trouble deserializing my case class. Although the serialization works great I can't get back the case class with the correct type for some reason.

This is my case class:

case class Team(
  id: ObjectId = new ObjectId,
  teamType: String = "",
  categories: List[String] = List(),
  entities: List[Map[String,String]] = List()
)

Like I said when I create a document or update a document it works perfectly but then when I do a query I get back an object like this

List(Team(52165d582736bd8a7e67ce3a,,List(foo, bar, baz),List({ "id" : "52165d582736bd8a7e67ce39" , "name" : "testuser"})))

It's List({ "id" : "52165d582736bd8a7e67ce39" , "name" : "testuser"}) part that I can't figure out.

How can I get it to deserialize as List(Map( "id" -> "52165d582736bd8a7e67ce39" , "name" -> "testuser"))?


Solution

  • As I replied to you on the Salat mailing list, Salat doesn't support deserializing nested collections right now.

    https://github.com/salat/salat/wiki/Collections