簡體   English   中英

遍歷JSONResult中的數據

[英]Loop through data in a JSONResult

有沒有一種方法可以使用索引值而不是鍵來遍歷JSON結果? 我想瀏覽json數據結果並獲取發送過來的鍵和值。

例如

 $.get('/Home/GetTypes', function (data) 
      {
       $.each(function(index) {
           //Just as an example I know this will not work. Thanks
         '<a class="p-button" href="/Wizard/Create/" + data[index][value] + " '">' + data[index][key] + '</a>' 
        }     

       });

假設數據是一個字典數組,那么您將很接近:

 $.each(data, function(index, obj) {
      // then obj and data[index] both point to the nth entry in data
for (key in data) {
    key = the key name
    data[key] = the value
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM