admin管理员组文章数量:1321243
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.
Thank you for your time.
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.
Thank you for your time.
Share Improve this question asked Jun 26, 2009 at 18:58 Alec SmartAlec Smart 96k39 gold badges124 silver badges186 bronze badges 3- How are you iterating through it? Are you parsing it, or are you evaling it? Do you need just certain parts? – cgp Commented Jun 26, 2009 at 19:02
- some good clientside parsing & performance tips from flickr – redsquare Commented Jun 26, 2009 at 19:09
- What is the structure of this json..? just a huge object or a huge array of objects..? – T J Commented Jan 17, 2016 at 6:09
2 Answers
Reset to default 1How about using the regular javascript functions?
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)'.
Hope to be still in time!
How about a simple -for-?
for(i = 0; i < data.length; i++) {
data[i].property = 'todo';
}
Otherwise -for in-
var mycars = [{name:'Ferrari'}, {name:'BMW'}];
for (i in mycars)
{
document.write(mycars[i].name + "<br />");
}
Here is the plete answer: How do I iterate over a JSON structure?
本文标签: jqueryFastest way to iterate through JSON string in JavascriptStack Overflow
版权声明:本文标题:jquery - Fastest way to iterate through JSON string in Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742097671a2420648.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论