原创文章转载请注明出处:@协思, http://zeeman.cnblogs.com
在分布式系统中,数据序列化传递的情形非常常见,主流的三种,JSON、XML、Protobuf。
XML现在已经很少使用,除非要和遗留系统交互。
JSON用在前端交互和跨组织的API的交互场合比较多。
对于内部系统,特别是性能敏感的区域,推荐使用Protobuf,可以得到最快的序列化速度和最小的结果。
参考资料:
http://stackoverflow.com/questions/14028293/google-protocol-buffers-vs-json-vs-xml
Json
human readable/editable
can be parsed without knowing schema in advance
excellent browser support
less verbose than XML
XML
human readable/editable
can be parsed without knowing schema in advance
standard for SOAP etc
good tooling support (xsd, xslt, sax, dom, etc)
pretty verbose
Protobuf
very dense data (small output)
hard to robustly decode without knowing the schema (data format is internally ambiguous, and needs schema to clarify)
very fast processing
not intended for human eyes (dense binary)
All have good support on most platforms.
作者:协思
出处:http://zeeman.cnblogs.com/
QQ交流群:32972862