0

I get a .proto definition as a string input, can I load it into a Root object straight from the string, for example the string might look like this

let protoStr = `syntax = "proto3";

message SearchRequest {
  string query = 1;
  int32 page_number = 2;
  int32 result_per_page = 3;
}`

And I want to be able to load it

let searchRequest = protobuf.loadFromStr(protoStr)
4

1 回答 1

1

是的,您可以使用protobuf.parse查看https://github.com/protobufjs/protobuf.js/blob/master/examples/custom-get-set.js#L7-L12

于 2022-01-30T14:00:09.843 回答