-1

我有如下所示的 JSON:

[
    {
        "Date": "2009-07-06",
        "Open": "406.50",
        "High": "410.64",
        "Low": "401.66",
        "Close": "409.61",
        "Volume": "2262600",
        "Adj Close": "409.61"
    },
    {
        "Date": "2009-07-02",
        "Open": "415.41",
        "High": "415.41",
        "Low": "406.81",
        "Close": "408.49",
        "Volume": "2517600",
        "Adj Close": "408.49"
    }
]

我确信它是有效的 JSON,但我不确定如何使用 jQuery 的 $.parseJSON() 解析它。我遇到了一个问题,因为这两个主要团体没有头衔,我想。它创建了一个对象列表,但我不知道如何访问这些对象。有什么建议么?谢谢!

4

1 回答 1

1

它创建一个对象数组,如下所示:

var json = '[{"Date": "2009-07-06","Open": "406.50","High": "410.64","Low": "401.66","Close": "409.61","Volume": "2262600","Adj Close": "409.61"},{"Date": "2009-07-02","Open": "415.41","High": "415.41","Low": "406.81","Close": "408.49","Volume": "2517600","Adj Close": "408.49"}]';

var valid = $.parseJSON(json);

访问喜欢

valid[0]; // first one
valid[1]; // second one
valid[1].Open; //Open in second one

小提琴

于 2013-03-16T22:11:18.397 回答