I just the answer in this post How to convert a Data Class to ByteBuffer in Kotlin?
And it works as expected. The problem is that nearly all data types are possible t