【发布时间】:2022-02-01 00:29:34
【问题描述】:
我正在尝试打印 proto 文件的消息正文的内容。但是我下面的代码也在打印我不想要的导入详细信息。有关如何过滤此内容以便仅打印消息内容的任何建议。
FileInputStream fin = new FileInputStream("mymessages.desc");
Descriptors.FileDescriptorSet set = Descriptors.FileDescriptorSet.parseFrom(fin);
for(FileDescriptorProto fileDesc : set.getFileList()){
List<DescriptorProto> descList = fileDesc.getMessageTypeList();
for(DescriptorProto desc : descList ){
System.out.Println(desc) ; // print all proto info including the imported field as well as message
}
}
}
我的原型文件
syntax = "proto3"
import "validate.proto";
message User{
string firstName = 1;
string lastName = 2;
}
【问题讨论】:
标签: java protocol-buffers protocols