JavaScript中json使用自己總結

來源:互聯網
上載者:User

自己總結json的使用:
複製代碼 代碼如下:
var json = { "100_3322.JPG": { "name": "小張", "height": 175 },
"100_3396.JPG": { "name": "小王", "height": 165 },
"100_3444.JPG": { "name": "貂蟬", "height": 185 }, "100_3543.JPG": { "name": "西施", "height": 190 }
};

key擷取的是100——3322.JPG 等

key.name 擷取的是 小張等

key.height擷取的是 175等

================================================
複製代碼 代碼如下:
var json = [{ "name": "baidu", "href": "http://www.baidu.com" }, { "name": "cnbeta", "href": "http://www.cnbeta.com" }, { "name": "cnblogs", "href": "http://www.cnblogs.com"}];

可以在遍曆的時候使用

json[i].href 擷取每個連結值

json[i].name 擷取每個連結名稱

================================================
複製代碼 代碼如下:
var json = { "河北省": ["石家莊", "邯鄲", "保定"],
"河南省": ["鄭州", "洛陽", "安陽"],
"山東省": ["濟南", "青島", "德州"]
}

key 擷取 河北省 等

json[key] 擷取 河北省 下面的數組內容 ["石家莊", "邯鄲", "保定"]

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.