ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 1. 释义 将一个JSON文档转换为protobuf格式数据。 ## 2. 使用方法 ``` ~$ configtxlator proto_encode --type=TYPE [<flags>] ``` 命令标志: ``` --help Show context-sensitive help (also try --help-long and --help-man). --type=TYPE The type of protobuf structure to encode to. For example, 'common.Config'. --input=/dev/stdin A file containing the JSON document. --output=/dev/stdout A file to write the output to. ``` ## 3. 示例代码 下面的示例将控制台输入的json格式的policy,转换为protobuf格式并存入文件policy.pb: ``` ~$ configtxlator proto_encode --type common.Policy --output policy.pb ``` 在启动rest服务后,下面的示例使用curl命令通过rest api执行同样的操作: ``` ~$ curl -X POST --data-binary /dev/stdin "${CONFIGTXLATOR_URL}/protolator/encode/common.Policy" > policy.pb ```