Avatar ·

How to create an empty constructor for data class in Kotlin Android?

Hello everyone! I'm a beginner in Kotlin and Android development, and I have a problem with data class. I want to use data class for a data model, but I need this class to have an empty constructor (no parameters) — for example, for deserialization from JSON in Retrofit or for use with Room. The problem is that when I write: ```kotlin data class User(val id: Int, val name: String) ``` Kotlin automatically generates a constructor only with these parameters. If I try to create an empty constructor: ```kotlin data class User(val id: Int, val name: String) { constructor() : this() // Error! } ``` The compiler gives an error: "There's a cycle in the delegation calls chain". I understand that data class requires all properties to be initialized, but how then