JSON format loop traversal, JSON array loop traversal

Source: Internet
Author: User

JSON format data How to traverse, here we can use for. In implementation

For example, the simplest JSON format

varJson1 = {'name':'Small Drill Wind',' Age': -,'Handsome':'Yes' }; for(varKeyinchJson1) {Console.log (Key+' : '+Json1[key]); }

Another version of the upgrade, as follows

varJson1 = {    'name': ['Echo','Small Drill Wind','Mom sells batches .','Small White Rabbit'],    ' Age': [' -',' -',' +',' -']}; for(varIinchJson1) {     for(varj =0; j<json1[i].length;j++) {Console.log (i+":"+json1[i][j])}}

The output is as follows

So how does the JSON array traverse it, as follows:

varJson1 = [{'name':'Echo',' Age':' -'},{'name':'Small Drill Wind',' Age':' -'},{'name':'Mom sells batches .',' Age':' +'}] for(vari =0; i<json1.length;i++){     for(varJinchJson1[i]) {Console.log (J+":"+json1[i][j])}}

This article is mainly for the convenience of personal memory and write, ideas for reference y_y1208 blog

JSON format loop traversal, JSON array loop traversal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.