JSON与XML的性能注意事项 [英] Performance considerations of JSON vs. XML

查看:95
本文介绍了JSON与XML的性能注意事项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用提供XML或JSON格式的大型结果集的Web服务. 哪种格式会更快或更佳(基于性能)?另外,我应该使用哪种语言来解析XML/JSON?我应该使用PHP还是JavaScript?

I am using a webservice which provides a large result set either in XML or JSON format. Which format will be faster or better (perfomance based)? Also which language should I use to parse the XML/JSON? Should I use PHP or JavaScript?

推荐答案

"PHP或JavaScript"听起来似乎很奇怪:PHP 通常用作服务器端语言,而JavaScript通常被用作客户端语言.

"PHP or JavaScript" sounds like an odd choice to offer: PHP is usually used as a server-side language, whereas JavaScript is usually used as a client-side language.

您的情况如何?是什么让您特别建议这两种语言?如果您可以提供有关您要做什么的更多信息,那将会很有帮助. (我们不知道您是否在开发Web应用程序,批处理工具,GUI应用程序等).

What's your situation? What makes you suggest those two languages in particular? If you could give more information about what you're trying to do, that would help a lot. (We don't know whether you're developing a web app, a batch processing tool, a GUI application, etc.)

我怀疑JSON会比XML紧凑,尽管如果他们压缩数据,您可能会发现它们最终会占用相同的带宽(因为XML的许多膨胀"很容易压缩).

I suspect JSON will be a bit more compact than XML, although if they're compressing the data you may well find they end up taking the same bandwith (as a lot of the "bloat" of XML is easily compressible).

与以往一样,找出答案的最佳方法是使用一些实际数据来测试特定的Web服务.笼统性不是决策的良好基础.

As ever, the best way to find out is to test the specific web service with some realistic data. Generalities aren't a good basis for decision-making.

这篇关于JSON与XML的性能注意事项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆