在Javascript中迭代JSON字符串的最快方法 [英] Fastest way to iterate through JSON string in Javascript
问题描述
我一直在使用$ .each的jQuery框架来迭代我通过AJAX调用收到的JSON字符串。现在这个字符串有时非常庞大,结果导致IE6 / 7/8爬行。
I have been using $.each of the jQuery framework to iterate through a JSON string that I receive via an AJAX call. Now this string is sometimes quite huge and as a result IE6/7/8 crawl as a result.
我想知道是否有更快的方法来遍历整个数据。
I am wondering if there is a faster way to iterate through the entire data.
感谢您的时间。
推荐答案
怎么样使用常规的javascript函数?
How about using the regular javascript functions?
例如,如果您有一个包含项目的JSON对象,您可以只需将JSON字符串转换为javascript对象,然后使用'for(对于它进行迭代)我在对象中)'。
If for example you have a JSON object with items in them, you could just eval the JSON string to convert it to javascript objects, and iterate over them using 'for (i in object)'.
这篇关于在Javascript中迭代JSON字符串的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!