Home >Web Front-end >JS Tutorial >JS simple method of looping through json array_javascript skills
The example in this article describes how to simply loop through a json array using JS. Share it with everyone for your reference, the details are as follows:
For example, the json string in the database is like this
var str = '[{"name":"宗2瓜","num":"1","price":"122"},{"name":"宗呱呱","num":"1","price":"100"}]'; var xqo = eval('(' + str + ')'); for(var i in xqo){ alert(xqo[i].name); }
The above is js, the following is jquery to parse json string,
var cc = jQuery.parseJSON(data); alert(cc[0].title);
For looping, it’s the same as above
For more JavaScript-related content, please check out the special topics on this site: "Summary of json operation skills in JavaScript", "Summary of JavaScript switching special effects and skills", "JavaScript Summary of Search Algorithm Techniques", "Summary of JavaScript Animation Special Effects and Techniques", "Summary of JavaScript Errors and Debugging Techniques", "Summary of JavaScript Data Structure and Algorithm Techniques ", "Summary of JavaScript traversal algorithms and techniques" and "Summary of JavaScript mathematical operation usage"
I hope this article will be helpful to everyone in JavaScript programming.