You're actually very close—you just need a few small changes. First, you can use nested case classes, but you'll need Reads
instances for each of them. I'll start with the inner one:
implicit val subWebCatReader: Reads[SubWebCat] = (
(__ \ 'name).read[String] and (__ \ 'id).read[String]
)(SubWebCat)
Note that I'm using symbols instead of strings in the paths; this is entirely a matter of personal preference (it's always good to be consistent, though). Note also the direction of the slashes—they should be backward, not forward.
We can apply these changes to your code and make one additional edit (to the part that reads the subcategory field) and we're done:
implicit val webCategoryReader: Reads[WebCategory] = (
(__ \ "top_group_name").read[String] and
(__ \ 'top_group_id).read[String] and
(__ \ 'web_category_name).read[String] and
(__ \ 'web_category_id).read[String] and
(__ \ 'sub_web_category).read[List[SubWebCat]]
)(WebCategory)
We know how to read a SubWebCat
, so we also know how to read a List[SubWebCat]
—no need to go through a map.