Create POJO Class for Kotlin

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

    data class VideoGame(val name: String, val publisher: String, var reviewScore: Int)
    //Constructor 
    val game: VideoGame = VideoGame("Gears of War", "Epic Games", 8)
    
    print(game.name) // "Gears of War"
    print(game.publisher) // "Epic Games"
    print(game.reviewScore) // 8
    game.reviewScore = 7
    

提交回复
热议问题