【发布时间】:2016-07-12 04:56:32
【问题描述】:
我正在使用implicit val reads 来映射 Json,例如:
{
"id": 1
"friends": [
{
"id": 1,
"since": ...
},
{
"id": 2,
"since": ...
},
{
"id": 3,
"since": ...
}
]
}
到一个案例类
case class Response(id: Long, friend_ids: Seq[Long])
我只能使它与反映 JSON friends 结构的中间类一起工作。但我从不在我的应用程序中使用它。有没有办法编写一个 Reads[Response] 对象,以便我的 Response 类直接映射到给定的 JSON?
【问题讨论】:
-
类似
case class Response(id: Long, friends: Seq[Friend])? -
这会起作用,但我没有也不想创建
Friend类。我只需要他们的身份证
标签: json scala playframework playframework-2.0 playframework-json