资料类别:
data class Topic(
@SerializedName("id") val id: Long,
@SerializedName("name") val name: String,
@SerializedName("image") val image: String,
@SerializedName("description") val description: String
)
到JSON:
val gson = Gson()
val json = gson.toJson(topic)
从JSON:
val json = getJson()
val topic = gson.fromJson(json, Topic::class.java)