Skip to content

Instantly share code, notes, and snippets.

@hissain
Created May 6, 2020 21:17
Show Gist options
  • Save hissain/7b920af677da4471d3a2fcddc66484d7 to your computer and use it in GitHub Desktop.
Save hissain/7b920af677da4471d3a2fcddc66484d7 to your computer and use it in GitHub Desktop.
data class Student(
@SerializedName("key_name")
var name: String? = null,
@SerializedName("key_address")
var address: String? = null) {
}
val student = Student("Mark", "London, 12000") // object
val json = Gson().toJson(student) // json string
/** Output json will be like below **/
{
"key_name": "Mark",
"key_address": "London, 12000"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment