title: Retrofit and Moshi: parsing variable name objects
body: <p>I'm using Retrofit 2 and Moshi to read and parse JSON from an endpoint.  My retrofit instance is defined like so:</p>
  
  <pre><code>val retrofit: Retrofit = Retrofit.Builder()
         .baseUrl("https://myendpoint.com")
         .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
         .addConverterFactory(MoshiConverterFactory.create())
         .build()
  </code></pre>
  
  <p>And I'm using the Kotlin data class to store the information in a model:</p>
  
  <pre><code>@GET("data/getlist")
  fun getData(): Single&lt;Data&gt;
  </code></pre>
  
  <p>Data class:</p>
  
  <pre><code>data class Data(val Response : String,
              val Message : String,
              val BaseImageUrl : String)
  </code></pre>
  
  <p>Now, because the JSON is formatted like so, the JSON is parsed and the model is populated just fine:</p>
  
  <pre><code>{
      "Response": "Success",
      "Message": "Api successfully returned",
      "BaseImageUrl": "https://www.endpoint.com/image/xxx.jpg",
  }
  </code></pre>
  
  <p>This is because the objects map 1:1 with the model. So in the above example, the "Response" key mapped to the "Response" variable name in the Data class.</p>
  
  <p>My question is this: what if the keys are all variable? How can you represent this in the Kotlin data class?</p>
  
  <p>Sample JSON file to be parsed:</p>
  
  <pre><code>{
      "RandomX": "xxxxxx",
      "RandomY": "yyyyyy",
      "RandomZ": "zzzzzz",
  }
  </code></pre>