I have been wondering if there is a possibility to automatically deserialize json to specific object properties, and serialize it with different names without implementing any custom deserializer. I am working on integrating my app with Github API and their naming convention is something I would like to remodel. Once requesting resources I get something like:
{
full_name: "...",
description: null,
clone_url: "...",
stargazers_count: 0,
created_at: "2018-06-05"
}
but I would like to expose them on my side as:
{
fullName: "...",
description: null,
cloneUrl: "...",
stars: 0,
createdAt: "2018-06-05"
}
Here is how my model looks like right now:
internal data class GithubRepositoryResponse(@JsonProperty("full_name") val fullName: String,
val description: String?,
@JsonProperty("clone_url") val cloneUrl: URL,
@JsonProperty("stargazers_count") val stars: Int,
@JsonProperty("created_at") val createdAt: LocalDate)
Using @JsonProperty
with value is bidirectional so I get the same property names as declared in annotation which is something I would really like to avoid. Is there any convenient way of dealing with such a scenerio?