title: Kotlin data class with SerializedName annotations variables in init block
body: <p>I have a data class below. Using coroutines and converting results as UserItem objects with gson. </p>
  
  <p>The problem is, in the init block the object is still uninitialized and the nick, images etc. variables are empty. Where should I write the code in the init block? </p>
  
  <pre><code>data class UserItem(
      @SerializedName("username") val nick: String = "",
      @SerializedName("full_name") val fullName: String = 0,
      @SerializedName("info") val bio: String = "",
      @SerializedName("images") val images: List&lt;String&gt; = 
  arrayListOf(),
      var imageType: ImageType = ImageType.NO_PHOTO
  ){
      companion object {
          @JvmStatic
          val DISPLAY_TYPE_USER = 0
          @JvmStatic
          val DISPLAY_TYPE_INFO = 1
      }
  
      enum class ImageType {
          NO_PHOTO, SINGLE_PHOTO, MULTIPLE_PHOTO
      }
  
      init {
          if (images.size == 1)
              imageType = ImageType.SINGLE_PHOTO
          else if (images.size &gt; 1)
              imageType = ImageType.MULTIPLE_PHOTO
      }
  }
  </code></pre>