scala play reads parse nested json

Viewed 3898

I'm using implicit val reads to map Json like:

{
   "id": 1
   "friends": [
    {
      "id": 1,
      "since": ...
    },
    {
      "id": 2,
      "since": ...
    },
    {
      "id": 3,
      "since": ...
    }
  ]
}

to a case class

case class Response(id: Long, friend_ids: Seq[Long])

I can only make it work with an intermediate class that reflects the JSON friends structure. But I never use it in my app. Is there a way to write a Reads[Response] object so that my Response class would map directly to the JSON given?

3 Answers
Related