title: Json data using kotlin
body: <p>I am currently working on an app and I would like to have a JSON extraction to a class but it's a little more difficult that just matching field. I am using Moshi for the JSON management.</p>
  
  <p>Below is the JSON I have : </p>
  
  <pre><code>{
    "common" :{
      "source_url": "xxxx",
      "target_url": "yyy
    },
    "specific":{
      "A":{
        "setting": "ccc",
      },
      "B":{
        "setting": "ddd",
      }
    }
  }
  </code></pre>
  
  <p>The goal for me is to get an object based on a data class which look like this:</p>
  
  <pre><code>data class config(
      val sourceUrl: String,
      val targetUrl: String,
      val setting: String
  )
  </code></pre>
  
  <p>What I have started is to first create the different data class to allow me to manipulate the data before getting the above class object.</p>
  
  <p>--GeneralConfig.kt</p>
  
  <pre><code>data class GeneralConfig(
      val common: CommonConfig,
      val specific: Specific
  )
  </code></pre>
  
  <p>-- CommonConfig.kt</p>
  
  <pre><code>data class CommonConfig(
      @Json(val name = "source_url") sourceUrl: String,
      @Json(val name = "target_url") val targetUrl: String
  )
  </code></pre>
  
  <p>-- SpecificConfig.kt</p>
  
  <pre><code>data class SpecificConfig(
      setting: String,
  )
  </code></pre>
  
  <p>I have 2 main questions:</p>
  
  <ul>
  <li><p>How can I access the "specific" "A/B" data and get an object class <code>SpecificConfig</code>. Can I in my <code>generalConfig</code> data class directly extract one field from <code>specific</code> and select <code>A</code> or <code>B</code> by passing an argument</p></li>
  <li><p>Is it possible to avoid creating multiple data class to get my final class object <code>config</code></p></li>
  </ul>
  
  <p>The purpose is to have a json containing a common data and specific data. I need to build a final data class which a merge from the common data and one of the specific data.</p>
  
  <p>Any idea ? Thanks</p>