how to check whether a data/payload can be decoded by protobuf or not

840 Views Asked by At

I have files with data (payload) in different formats (plain text, json, xlm, binary (can be decoded by protobuf)). To know how to process particular file I need to know what is the format of data in the file.

The question is whether it is possible to recognize without having .proto (message) file that the payload in a file can be decoded by protobuf. So, if I know that it is protobuf encoded data, I will apply one logic where .proto file is required, otherwise, another logic without .proto file.

All what I've found requires to have protobuf message to validate/decode.

1

There are 1 best solutions below

1
On

Usually .proto files have something like syntax = "proto3"; as one of the first lines of the file. This does not apply to proto2 syntax though.

Maybe you can make use of that?