Created
March 4, 2020 20:45
-
-
Save viartemev/78d4d640080c432dde6ed30d1be9f434 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun main() { | |
val mapper = jacksonObjectMapper() | |
val personData = MainDataData("name", "surname", 19) | |
val foo = Foo(personData, "foo") | |
val bar = Bar(personData, "bar") | |
println(mapper.writeValueAsString(foo)) | |
println(mapper.writeValueAsString(bar)) | |
} | |
interface MainData { | |
val name: String | |
val surname: String | |
val age: Int | |
} | |
data class MainDataData( | |
override val name: String, | |
override val surname: String, | |
override val age: Int | |
) : MainData | |
data class Foo( | |
@field:JsonUnwrapped | |
val data: MainData, | |
val foo: String | |
) : MainData by data | |
data class Bar( | |
@field:JsonUnwrapped | |
val data: MainData, | |
val bar: String | |
) : MainData by data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment