来自 announcement blog post 的评论:
Regarding JSON: JSON is structured similarly to Protocol Buffers, but protocol buffer binary format is still smaller and faster to encode. JSON makes a great text encoding for protocol buffers, though -- it's trivial to write an encoder/decoder that converts arbitrary protocol messages to and from JSON, using protobuf reflection. This is a good way to communicate with AJAX apps, since making the user download a full protobuf decoder when they visit your page might be too much.
制作 a 映射可能是微不足道的,但是在这两者之间是否存在任何两个独立的开发团队自然会选择的单一“明显”映射?如果两个产品支持 PB 数据并且可以互操作,因为它们共享相同的 .proto 规范,我想知道如果它们独立引入相同规范的 JSON 反射,它们是否仍然能够互操作。可能会有一些任意的决定,例如枚举值应该用字符串(典型的 JSON 可读)还是整数值来表示?
那么是否存在已建立的映射,以及任何用于从 .proto 规范生成 JSON 编码器/解码器的开源实现?
最佳答案
这可能会有所帮助http://code.google.com/p/protobuf-java-format/
https://stackoverflow.com/questions/2544580/
相关文章:
json - golang json编码(marshal): how to omit empty n
json - 来自 JSON 字符串的 typescript `enum`
javascript - JSON 无法解析的垃圾 : Why so serious?
javascript - 如何从对象中删除所有 null 和空字符串值?
javascript - 我应该如何在 JSON 中表示表格数据?
ajax - 何时将 Ajax 与 Json 用于 Javascript 事件?
json - 有什么方法可以在运行时使用 webpack 加载资源?