【问题标题】:How to use a case class to deserialize an array of json objects to List[Map[String,String]]如何使用案例类将 json 对象数组反序列化为 List[Map[String,String]]
【发布时间】:2013-08-22 18:59:32
【问题描述】:

我在反序列化我的案例类时遇到问题。尽管序列化效果很好,但由于某种原因,我无法以正确的类型取回案例类。

这是我的案例类:

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

就像我在创建文档或更新文档时所说的那样,它工作得很好,但是当我进行查询时,我会得到一个这样的对象

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

这是List({ "id" : "52165d582736bd8a7e67ce39" , "name" : "testuser"}) 部分我想不通。

我怎样才能让它反序列化为List(Map( "id" -> "52165d582736bd8a7e67ce39" , "name" -> "testuser"))?

【问题讨论】:

    标签: scala case-class casbah salat


    【解决方案1】:

    正如我在 Salat 邮件列表上回复你的,Salat 目前不支持反序列化嵌套集合。

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

    【讨论】:

      猜你喜欢
      • 2020-05-06
      • 2017-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-08
      • 1970-01-01
      • 2017-05-21
      • 2011-06-30
      相关资源
      最近更新 更多