我使用implicit val reads
到JSON映射,如:斯卡拉发挥读取解析嵌套的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])''? – mfirry
这将工作,但我没有,也不想创建“朋友”类。我只需要他们的ID –