Skip to content

Instantly share code, notes, and snippets.

@kamontat
Last active July 10, 2017 10:20
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 kamontat/b9db050189da24f9f9a0c2a436a8439d to your computer and use it in GitHub Desktop.
Save kamontat/b9db050189da24f9f9a0c2a436a8439d to your computer and use it in GitHub Desktop.
medium source code
// file name unnecessary to match with annotation name
// Target must matching (if not you will cannot get from annotations)
@Target(AnnotationTarget.VALUE_PARAMETER)
annotation class JsonKey(val key: String)
// make sure that type of each parameter matches with json object
// make sure that JsonKey match with key in json
/* import JsonKey */
data class Owner(
@JsonKey("login") val login: String,
@JsonKey("id") val id: Long,
@JsonKey("avatar_url") val avatar_url: String,
@JsonKey("url") val api_url: String,
@JsonKey("html_url") val html_url: String,
@JsonKey("followers_url") val followers_url: String,
@JsonKey("following_url") val following_url: String,
@JsonKey("organizations_url") val organizations_url: String,
@JsonKey("repos_url") val repos_url: String,
@JsonKey("type") val type: String,
@JsonKey("site_admin") val site_admin: Boolean,
@JsonKey("name") val name: String,
@JsonKey("company") val company: String,
@JsonKey("blog") val blog: String,
@JsonKey("location") val location: String,
@JsonKey("email") val email: String,
@JsonKey("hireable") val hireable: Boolean,
@JsonKey("bio") val bio: String,
@JsonKey("public_repos") val public_repos: Int,
@JsonKey("public_gists") val public_gists: Int,
@JsonKey("followers") val followers: Int,
@JsonKey("following") val following: Int,
@JsonKey("created_at") val created_at: String,
@JsonKey("updated_at") val updated_at: String
) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment