title: How to avoid definition of implicit reads/writes for the sub-classes for JSON Macro Inception (to convert nested JSON structure to Scala)
body: <p>I have a requirement where the incoming JSON object is complex and mostly nested ex:</p>
  
  <pre><code>"users": {
    "utype": "PERSON",
    "language":"en_FR",
    "credentials": [
      {          
        "handle": "xyz@abc.com",
        "password": "123456",
        "handle_type": "EMAIL"
      }
    ],
    "person_details": {
      "primary": "true",
      "names": [
        {
        "name_type": "OFFICIAL",
        "title": "MR",
        "given": "abc",
        "family": "zat",
        "middle": "pqs",
        "suffix":"anathan"
       }
      ],
      "addresses": [
        {
          "ad_type": "HOME",
          "line1": "Residential 2211 North 1st Street",
          "line2": "Bldg 17",
          "city": "test",
          "county": "Shefield",
          "state" : "NY",
          "country_code": "xx",
          "postal_code": "95131"
        }
      ]
    }
  }
  </code></pre>
  
  <p>For parsing this structure I use the below Case Classes</p>
  
  <pre><code>case class PersonUser (
      user_type:String,
      language_code:String,
      credentials:List[Credential],
      person_details:PersonDetails
  )
  
  case class Credential(handle:String, password:String,handle_type:String)
  
  case class PersonDetails(
      primary_user:Boolean,
      names: List[Name],
      addresses:List[Address]
  )
  
  case class Name(
      name_type: String,
      title: String,
      given: String,
      family: String,
      middle: String,
      suffix:String
  )
  
  case class Address(
      address_type: String,
      line1: String,
      line2: String,
      city: String,
      county: String,
      state : String,
      country_code: String,
      postal_code: String
  )
  </code></pre>
  
  <p>To convert the JSON structure to Scala I used JSON Inception:</p>
  
  <pre><code> implicit val testReads = Json.reads[PersonUser]
  </code></pre>
  
  <p>Also I had to specify similar <strong>reads implicits</strong> in the sub classes - <strong>Credential, PersonDetails, Name and Address. Given below on such instance:</strong></p>
  
  <pre><code>case class Credential(handle:String, password:String,handle_type:String)
  object Credential{
     implicit val reads = Json.reads[Credential]
  }
  </code></pre>
  
  <p>Now comes the question, if my JSON structure is really big with lots of sub-structures, there will be a number of Scala case classes I need to define. It will be really cumbersome to define companion objects and implicit read for each of the case classes (Ex: if I have 8 case classes to represent the JSON structure fully, I will have to define 8 more companion objects). Is there any way to avoid this extra work?</p>