Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open/view .proto file extension

I am working on an open-source project(https://github.com/google/science-journal/tree/master/OpenScienceJournal). With this application, I can record an experiment. Recorded experiments are stored with the .proto extension. I tried to compile them to generate classes but failed.

Is there any way to open this kind of files?

like image 818
blockByblock Avatar asked Oct 17 '25 13:10

blockByblock


1 Answers

In protocol-buffers, .proto files are usually the text-based schema DSL that describes messages, not data; however, it is possible that these files do indeed contain the binary data instead (just... unusual). Double-check the files : if they look like:

message Foo {
   int32 bar = 1;
   // etc
}

then it is the schema; if it is binary-looking, it is probably data.

As to how to read it: the simplest option is to already have the schema. If you don't, the data is technically ambiguous - you can probably reverse-engineer it by examining the data, but it can be awkward. You may find tools such as https://protogen.marcgravell.com/decode useful for that purpose.

Once you have a schema and the data, you would:

  • generate the necessary stubs in your chosen platform from the schema (https://protogen.marcgravell.com/ may be useful here)
  • then: use the protbuf library's "deserialize" API for your chosen platform to load the data into an object model
  • finally: inspect the object model, now populated with the data
like image 83
Marc Gravell Avatar answered Oct 19 '25 13:10

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!