Use a JSON array with objects with javascript

后端 未结 6 1577
执笔经年
执笔经年 2021-01-30 03:29

I have a function that will get a JSON array with objects. In the function I will be able to loop through the array, access a property and use that property. Like this:

6条回答
  •  借酒劲吻你
    2021-01-30 03:43

    This is your dataArray:

    [
       {
          "id":28,
          "Title":"Sweden"
       },
       {
          "id":56,
          "Title":"USA"
       },
       {
          "id":89,
          "Title":"England"
       }
    ]
    

    Then parseJson can be used:

    $(jQuery.parseJSON(JSON.stringify(dataArray))).each(function() {  
        var ID = this.id;
        var TITLE = this.Title;
    });
    

提交回复
热议问题