Monday, 21 January 2019

Model class Kotlin

I used a plugin in Android studio JSON to Kotlin Data class Converter.
Which automatically converted above JSON List to the below Kotlin Data Class Post.

import com.google.gson.annotations.SerializedName


data class Post(
      @SerializedName("userId") val userId: Int,
      @SerializedName("id") val id: Int,
      @SerializedName("title") val title: String,
      @SerializedName("body") val body: String
)

No comments:

Post a Comment