Сериализация / Бинарный формат

import com.fasterxml.jackson.databind.ObjectMapper

class Size {
    var width: Int = 0
    var height: Int = 0
}

class Rect {
    var size: Size = Size()
}

val size = Size()
size.width = 5
size.height = 10

val rect = Rect()
rect.size = size

val mapper = ObjectMapper()
val dataB = mapper.writeValueAsBytes(rect)

val rect2 = mapper.readValue(dataB,
    Rect::class.java)

println("width is ${rect2.size.width}")
println("height is ${rect2.size.height}")