Create POJO Class for Kotlin

前端 未结 10 1899
闹比i
闹比i 2021-02-03 18:34

I want to create POJO class for Kotlin, as we know that www.jsonschema2pojo.org converts JSON to POJO so we can use it with gson.

Anyone know how to create Gson POJO for

10条回答
  •  北荒
    北荒 (楼主)
    2021-02-03 19:18

    data class ModelUser(val imagePath: String,val userName: String)
    

    Unbelievable Right! Its as simple as that. Just use data keyword before class to create Data class in Kotlin.

    Data class provides you with everything, getters, setters, hashCode, toString and equals functions. So all you have to do is create an instance and start using the functions.

提交回复
热议问题