我使用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 –