Create POJO Class for Kotlin

前端 未结 10 1900
闹比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:17

    Try this

    This is the simple way

    1. Right click on the package name and select New->Kotlin File/Class
    2. Name the name, In my case, I am naming this as Model you can whatever you like and click on ok
    3. and Paste this code, This is you POJO/Model class

      class Model {
          var uid: String? = null
          var name: String? = null
      }
      

    How to use this

     val model=Model()
     model.name="Sunil"
     Log.e("Model after",model.name)
    

提交回复
热议问题