Skip to content

Instantly share code, notes, and snippets.

@hissain
Created May 6, 2020 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissain/dcff0a50b743d777d7785ba217304232 to your computer and use it in GitHub Desktop.
Save hissain/dcff0a50b743d777d7785ba217304232 to your computer and use it in GitHub Desktop.
class StudentSerializer : JsonSerializer<Student> {
override fun serialize(src: Student?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement {
val jsonObject = JsonObject()
try {
jsonObject.add("name", context?.serialize(src.name))
jsonObject.add("address", JsonParser().parse(src.address))
}catch (e: Exception){
Logger.e(Tag, e)
}
return jsonObject
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment