Google协议缓冲区:JavaScript示例 [英] Google Protocol Buffers: JavaScript Example
问题描述
在JavaScript中使用Google协议缓冲区是一个不错的选择,还是用JSON更好呢?
Is it a good choice to use Google Protocol Buffers in JavaScript or is it better to do it with JSON?
如果有人能给我一个关于JavaScript中协议缓冲区实现的简单示例,那也很好. Google网站上的文档很少.
Also it'd be great if someone can give me a simple example about Protocol Buffers implementation in JavaScript. The documentation on the Google's site is scarce.
推荐答案
[edit] Google's open source implementation of protocol buffers is available on github
protobuf官方项目仅支持Java,C ++和Python.不是Java语言.
The official protobuf project support only Java, C++, and Python. Not Javascript.
根据该项目的Wiki,有三个项目将协议缓冲区移植到Javascript.
According to the Wiki of the project, there are three projects porting protocol buffers to Javascript.
- Protobuf.js: https://github.com/dcodeIO/ProtoBuf.js
- protobuf-js: http://code.google.com/p/protobuf-js /
- protojs: http://github.com/sirikata/protojs
- Protobuf.js: https://github.com/dcodeIO/ProtoBuf.js
- protobuf-js: http://code.google.com/p/protobuf-js/
- protojs: http://github.com/sirikata/protojs
Protobuf.js是最新的. protobuf-js已有两年没有更新,因此,我希望使用Protobuf.js.
Protobuf.js is up-to-date. protobuf-js has not been updated for two years, so I would favor Protobuf.js.
问题仍然是为什么"?:protobuf可能会更小,尤其是在传输大量数值时,但是JSON是JS空间中更常见的协议,并且可能得到更好的支持并且更易于集成到其中其他工具.
The question still is "Why"?: protobuf may be a bit smaller, especially when a lot of numeric values are transferred, but JSON is simply the more common protocol in the JS space and probably better supported and easier to integrate into other tools.
这篇关于Google协议缓冲区:JavaScript示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!