评估responseText/responseXML性能

发布于 2024-09-18 08:15:00 字数 220 浏览 1 评论 0原文

有谁知道使用 eval()responseText (使用 JSON)是否比仅使用 responseXML 更快或更慢?

我认为避免使用 eval() 并使用 responseXML 会更快,尽管事实上您必须编写很长的代码才能实际获取 XML 的值。

谢谢。

Does anyone readily know if using eval() and responseText (using JSON) is faster or slower than just using responseXML?

I would imagine avoiding the eval() and using responseXML instead would be faster, despite the fact that you gotta write really long code to actually get the values of the XML.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丶情人眼里出诗心の 2024-09-25 08:15:00

实际上,JSON 数据大多数时候都比 XML 小。

最好不要使用eval(),因为这是一个众所周知的安全漏洞。但我听说过正则表达式可以检查 JSON 合规性。

我不喜欢 XML,所以我避免使用它,但我认为 responseXML 将构建一个 DOM 模型,该模型比 responseText 创建的本机 javascript 对象重得多,

我想最大限度地减少带宽 JSON 是可能是比 XML 更好的选择。

Actually JSON data are most of the time smaller than XML.

It is better to not use eval() because it is a well known security leak. But I've heard of regular expression which can check the JSON compliance.

I do not like XML so I avoid it, but I suppose that the responseXML will build a DOM model which is much more heavier than the native javascript objects created by responseText

I you want to minimize the bandwidth JSON is probably a better choice than XML.

童话 2024-09-25 08:15:00

使用 JSON 并使用解析器而不是 eval。这是一个 - https://github.com/douglascrockford/JSON-js

Use JSON and use a parser instead of eval. Here's one - https://github.com/douglascrockford/JSON-js

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文