srisindhu saride
srisindhu saride

Reputation: 431

Kotlin Data Classes support in Protobuf

I am implementing protobuf recently in our kotlin project. I am receiving the binary data and deserialising it to Proto object using the proto file.

But I would like have that converted to data class. I could not find any supporting information about how to do this.

Is it possible to get data class from binary data or from deserialized proto object??

Upvotes: 1

Views: 7696

Answers (2)

Benni
Benni

Reputation: 385

If you have know the structure of the data and can write your data classes upfront, you might want to have a look at kotlinx.serialization. It is an official Kotlin project and supports protobuf out-of-the-box.

Upvotes: -1

William Reed
William Reed

Reputation: 1844

One solution might be to use pb-and-k which has the kotlin code generator and will generate data classes for you based off of the .proto files

Upvotes: 1

Related Questions