Piotr Prus
01/18/2021, 2:11 PMserialization-protobuf
to deserialize protobuf byte to kotlin data class ( I do not know if that is even possible). I found this article:
https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-protobuf/kotlinx[…]alization-protobuf/kotlinx.serialization.protobuf/index.html
and tried to use simple data class for protobuf response.
the proto file :
syntax = "proto2";
package test_test;
option optimize_for = LITE_RUNTIME;
option go_package = "test;test";
message Test {
message Layer {
required uint32 id = 1;
repeated int32 geometry = 2 [ packed = true ];
}
repeated Layer layers = 1;
}
and here is my data class:
import kotlinx.serialization.Serializable
@Serializable
data class Test(
val layers: List<Layer> = listOf()
)
@Serializable
data class Layer(
val id: Int,
val geometry: List<Int> = listOf()
)
The question is. Is that even possible? Or I am doing it wrongly?