![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
protobuf
空腹熊猫
普通后台开发,喜欢看源码,对机器学习深度学习感兴趣
展开
-
protobuf JsonStringToMessage 遇到bytes字段报错
在用proto协议的系统中,写自测用具用到json转pb的函数,但是如果proto协议中有bytes字段,纯json转pb就会报错,以下函数返回falseJsonStringToMessage(test_msg, &message).ok()查资料发现bytes 字段要先进行base64编码,再放到json里,这样就能成功解析成pb对象了。参考:https://github.com/protocolbuffers/protobuf/issues/5719https://github原创 2021-09-14 11:21:08 · 2029 阅读 · 0 评论 -
protobuf 编译proto文件报错:Missing output directives.
这个错误是因为没有指定输出格式,正确的编译方式应该是:/usr/bin/protoc -I=. --cpp_out=. xxx.proto要指定语言原创 2020-01-20 15:04:19 · 8037 阅读 · 1 评论 -
protobuf 编译proto文件报错:No syntax specified for the proto file
细看错误可以找到说明:Please use 'syntax = "proto2";' or 'syntax = "proto3";' to specify a syntax version. (Defaulted to proto2 syntax.)在proto文件最开头加上:syntax = "proto2";或syntax = "proto3";即可...原创 2020-01-20 14:57:42 · 6590 阅读 · 0 评论 -
protobuf 学习总结——protobuf 简单使用
1、protobuf 安装安装好的目录如下:protobuf-2.4.1/|-- bin|-- include`-- lib2、创建一个proto文件package PAY;message Person { optional int32 age = 1; optional bytes name = 2;}3、创建wr...原创 2018-12-21 11:24:04 · 244 阅读 · 0 评论 -
protobuf 解析错误 ParseFromArray 时返回false
protobuf 结构在反序列化ParseFromArray 时返回false原因:proto文件结构 序列号/反序列化没对上或者是proto 定义里require 的字段没有填,都可能导致以上错误...原创 2019-07-18 17:45:44 · 5917 阅读 · 0 评论