protobuf与json互相转换,protobuf输出字符串
来源:互联网 发布:linux 压缩命令 zip 编辑:程序博客网 时间:2024/06/05 22:40
protobuf与json互相转换,protobuf输出字符串
Java
http://code.google.com/p/protobuf-java-format/
maven
<dependency>
<groupId>com.googlecode.protobuf-java-format</groupId>
<artifactId>protobuf-java-format</artifactId>
<version>1.2</version>
</dependency>
从protobuf转json
Message someProto =SomeProto.getDefaultInstance();String jsonFormat =JsonFormat.printToString(someProto);
从json转protobuf
Message.Builder builder =SomeProto.newBuilder();String jsonFormat = _load json document from a source_;JsonFormat.merge(jsonFormat, builder);
C++
https://github.com/shramov/json2pb
---------------------------------------------------------------------------Provide serialization and de-serialization of different formats based on Google’s protobuf Message. Enables overriding the default (byte array) output to text based formats such as XML, JSON and HTML.
Fork from http://code.google.com/p/protobuf-java-format
Description
Provide serialization and de-serialization of different formats based on Google’s protobuf Message. Enables overriding the default (byte array) output to text based formats such as XML, JSON and HTML.
##Example For XML output, use XmlFormat
Message someProto = SomeProto.getDefaultInstance();String xmlFormat = XmlFormat.printToString(someProto);
For XML input, use XmlFormat
Message.Builder builder = SomeProto.newBuilder();String xmlFormat = _load xml document from a source_;XmlFormat.merge(xmlFormat, builder);
For Json output, use JsonFormat
Message someProto = SomeProto.getDefaultInstance();String jsonFormat = JsonFormat.printToString(someProto);
For Json input, use JsonFormat
Message.Builder builder = SomeProto.newBuilder();String jsonFormat = _load json document from a source_;JsonFormat.merge(jsonFormat, builder);
For HTML output, use HtmlFormat
Message someProto = SomeProto.getDefaultInstance();String htmlFormat = HtmlFormat.printToString(someProto);
- protobuf与json互相转换,protobuf输出字符串
- protobuf与json互相转换
- Protobuf与JSON互相转换
- Protobuf与JSON互相转换
- protobuf与json互相转换
- Protobuf与Json互转
- 字符串与json互相转换
- protobuf 与xml,还有json
- json字符串与java对象互相转换
- Json字符串与Java对象互相转换
- json字符串与 js对象互相转换
- JSON 字符串 互相转换
- xml、json、protobuf、thrift与avro
- json与protobuf的速度之争
- protobuf
- ProtoBuf
- protobuf
- protobuf
- Andriod Studio中引用aar jar so
- 骨骼蒙皮动画(Skinned Mesh)的原理解析(二)
- vue2.0父子组件间通信
- android popupWindow
- Android 倒计时
- protobuf与json互相转换,protobuf输出字符串
- C++ 11 4
- SpringMvc知识 (2)
- win10自带Hyper-v配置虚拟网络
- 集合
- javaScript的三种创建方式
- NSNotificationCenter 的使用详解
- 反射
- Java生成缩略图Thumbnailator(转载)