Gson Deserialization with Kotlin, Initializer block not called : <p>My initializer block is working perfectly fine when I create my Object</p>

<pre><code>class ObjectToDeserialize(var someString: String = "") : Serializable {
    init{
        someString += " initialized"
    }
}
</code></pre>

<p>this way:</p>

<pre><code>@Test
fun createObject_checkIfInitialized() {
      assertEquals("someString initialized",ObjectToDeserialize("someString").someString)
}
</code></pre>

<p>But when I deserialize the object with Gson, the initializer block does not get executed:</p>

<pre><code>@Test
fun deserializeObject_checkIfInitialized(){
    val someJson: String = "{\"someString\":\"someString\" }"
    val jsonObject = Gson().fromJson(someJson, ObjectToDeserialize::class.java)

    assertEquals("someString initialized",jsonObject.someString)

    // Expected :someString initialized
    // Actual   :someString
}
</code></pre>

<p>I think that gson is creating the object in a different way than by executing the primary constructor. Is it nevertheless possible to have something similar like initializer blocks?</p>

<hr>
