草庐IT

ProtoBuf

全部标签

java - 如何在 protobuf 消息中添加一个 int 数组

我必须编写一个protobuf消息,它应该有1个整数变量和一个整数数组。packageprotobuf;messagemyProto{optionaluint32message_id=1;optionalintupdate=2;//hereIhavetoaddaarrayofintegers//canIwritelikeoptionalint[]array=3;//orshouldIuseoptionalrepeatedarray;//wherearrayisanothermessagewithintvariable}我的方法正确吗? 最佳答案

c++ - Protobuf : Will set_allocated_* delete the allocated object?

我有这个小protobuf代码(简化,只包含必要的):messageParamsMessage{requiredint32temperature=1;}messageMasterMessage{enumType{GETPARAMS=1;SENDPARAMS=2;}requiredTypetype=1;optionalParamsMessageparamsMessage=2;}我现在通过以下方式创建MasterMessage:ParamsMessage*params=newParamsMessage();params->set_temperature(22);MasterMessagem

c++ - 如何从一组已定义的描述符中动态构建新的 protobuf?

在我的服务器上,我们收到self描述的消息(定义为here...顺便说一句,这并不容易,因为在c++中没有任何“好的”示例)。在这一点上,我从这些self描述的消息中创建消息没有问题。我可以拿FileDescriptorSet,遍历每一个FileDescriptorProto,将每个添加到DescriptorPool(使用BuildFile,这也给了我每个定义的FileDescriptor)。从这里我可以创建在FileDescriptorSet中定义的任何消息,其中DynamicMessageFactory使用DP实例化并调用GetPrototype(这很容易做到,因为我们的SelfD

go - 无法构建 protobuf 去端点

使用protobuf版本2.6.1(我通过自制软件安装)我正在尝试运行$protoc--go_out=../cloud/*.proto我不断收到此错误。$protoc-gen-go:programnotfoundorisnotexecutable$--go_out:protoc-gen-go:Pluginfailedwithstatuscode1.我的go路径中安装了protoc-gen-go。其他人有这个问题吗? 最佳答案 protoc-gen-go需要在您的shell路径中,即PATH环境变量中列出的目录之一,其中不同于Go路径

c++ - Google Protocol Buffer 比较

我想比较Googleprotocolbuffers的两个消息或(两个子参数).我没有找到实现它的API。有什么想法吗? 最佳答案 你可以使用类google::protobuf::util::MessageDifferencer为了这。我认为它仅在v3.0.2之后可用:Introducednewutilityfunctions/classesinthegoogle/protobuf/utildirectory:MessageDifferencer:comparetwoprotomessagesandreporttheirdiffere

c++ - Google Protocol Buffer 比较

我想比较Googleprotocolbuffers的两个消息或(两个子参数).我没有找到实现它的API。有什么想法吗? 最佳答案 你可以使用类google::protobuf::util::MessageDifferencer为了这。我认为它仅在v3.0.2之后可用:Introducednewutilityfunctions/classesinthegoogle/protobuf/utildirectory:MessageDifferencer:comparetwoprotomessagesandreporttheirdiffere

protobuf序列化

文章目录protubufprotobuf序列化protobuf的原理定义message编译message文件应用protobufMessage基本用法Message嵌套使用protubufprotobuf序列化protobuf是一种比json和xml等序列化工具更加轻量和高效的结构化数据存储格式,性能比json和xml真的强很多,毕竟google出品。protobuf的原理定义message协议的模板所有的message必须定义到一个文件中,且文件的后缀名为.proto。例如我们定义的bike.proto文件required:必须填发送的数据bike.protosyntax="proto2";

protobuf序列化

文章目录protubufprotobuf序列化protobuf的原理定义message编译message文件应用protobufMessage基本用法Message嵌套使用protubufprotobuf序列化protobuf是一种比json和xml等序列化工具更加轻量和高效的结构化数据存储格式,性能比json和xml真的强很多,毕竟google出品。protobuf的原理定义message协议的模板所有的message必须定义到一个文件中,且文件的后缀名为.proto。例如我们定义的bike.proto文件required:必须填发送的数据bike.protosyntax="proto2";

python - python中的protobuf到json

我有一个对象,我在Python中使用protobuf进行反序列化。当我打印该对象时,它看起来像一个python对象,但是当我尝试将其转换为json时,我遇到了各种各样的问题。例如,如果我使用json.dumps()我会发现对象(从protoc生成的代码)不包含_dict_错误。如果我使用jsonpickle,我会得到UnicodeDecodeError:'utf8'codeccan'tdecodebyte0x9dinposition97:invalidstartbyte。下面的测试代码正在使用jsonpickle并出现上面显示的错误。iflen(sys.argv)

python - python中的protobuf到json

我有一个对象,我在Python中使用protobuf进行反序列化。当我打印该对象时,它看起来像一个python对象,但是当我尝试将其转换为json时,我遇到了各种各样的问题。例如,如果我使用json.dumps()我会发现对象(从protoc生成的代码)不包含_dict_错误。如果我使用jsonpickle,我会得到UnicodeDecodeError:'utf8'codeccan'tdecodebyte0x9dinposition97:invalidstartbyte。下面的测试代码正在使用jsonpickle并出现上面显示的错误。iflen(sys.argv)