Last active
February 20, 2021 05:09
-
-
Save SeongUgJung/6297162e95670f777c98e6df47aac476 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
// this will generate PersonAdapter.kt | |
@JsonClass(generateAdapter = true) | |
data class Person( | |
val name: String, | |
val age: Int, | |
val phone: Phone | |
) | |
class PersonAdapterFactory : JsonAdapter.Factory { | |
overridee fun create(type: Type, moshi: Moshi) = | |
if (type == Person::class.java) PersonAdapter(moshi) else null | |
} | |
// this will generate PhoneAdapter.kt | |
@JsonClass(generateAdapter = true) | |
data class Phone( | |
val mobile: String, | |
val home: String, | |
val office: String | |
) | |
class PhoneAdapterFactory : JsonAdapter.Factory { | |
overridee fun create(type: Type, moshi: Moshi) = | |
if (type == Phone::class.java) PhoneAdapter(moshi) else null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment