Created
May 6, 2020 21:21
-
-
Save hissain/dcff0a50b743d777d7785ba217304232 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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