title: Parsing empty object with kotlinx.serialization
body: <p>I am struggling to understand how to parse an empty object <code>{}</code> with the experimental <code>kotlinx.serialization</code> library. The complication arises when in fact an API response can be one of;</p>
  
  <pre><code>{
    "id": "ABC1",
    "status": "A_STATUS"
  }
  </code></pre>
  
  <p><em>or</em></p>
  
  <pre><code>{}
  </code></pre>
  
  <p>The data structure I have used as my serializer is;</p>
  
  <pre><code>data class Thing(val id: String = "", val status: String = "")
  </code></pre>
  
  <p>This is annotated with <code>@kotlinx.serialization.Serializable</code> and used within an API client library to marshall between the raw API response and the data model. The default values tell the serialisation library that the field is optional and replaces the <code>@Optional</code> approach of pre-Kotlin 1.3.30.</p>
  
  <p>Finally, the <code>kotlinx.serialization.json.Json</code> parser I am using has the configuration applied by using the <code>nonstrict</code> template.</p>
  
  <p>How do I define a serializer that can parse both an empty object and the expected data type with <code>kotlinx.serialization</code>? Do I need to write my own <code>KSerialiser</code> or is there config I am missing. Ideally, the empty object should be ignored/parsed as a <code>null</code>?</p>
  
  <p>The error I get when parsing an empty object with my <code>Thing</code> data class is;</p>
  
  <pre><code>Field 'id' is required, but it was missing
  </code></pre>