protobuf-java-format

Protobuf与JSON互相转换

 ̄綄美尐妖づ 提交于 2020-08-15 05:56:31
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 from source; JsonFormat.merge(jsonFormat, builder); 来源: oschina 链接: https://my.oschina.net/u/4335726/blog/4399904

【微服务】序列化协议 In Action

孤街浪徒 提交于 2020-03-25 11:42:02
3 月,跳不动了?>>> 本文就常见的几种序列化协议介绍下简单的实践 ProtoBuf ProtoBuf 是有谷歌开源,可以跨语言,可编译成各种语言。可称之为一个IDL, Interface description language. 下载编译器,protoc protoc-3.11.4-osx-x86_64.zip;可下载不同操作系统的版本, https://github.com/google/protobuf/releases 设置环境变量 vi ~/.bash_profile export PATH=$PATH:/path/to/protoc-3.4.0/bin 在maven项目中引入相关依赖 <!-- https://mvnrepository.com/artifact/com.google.protobuf/protobuf-java --> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> <version>3.11.4</version> </dependency> <!-- https://mvnrepository.com/artifact/com.googlecode.protobuf-java-format/protobuf