目前我正在使用以下代码来显示 JSON 数据文件的部分内容:
$.getJSON( 
    "json.json",
    function(data) {
        $.each(data.events, function() {
            $('#listings').append("<p>" + this['eventname'] + "</p><p>" + this['eventurl'] + "</p><p>" + this['dates[startdate]'] + "</p>");
        });
    }
);
这是我从中检索数据的本地缓存和创建的 JSON 文件的一部分。
"events": [
    {
        "eventid": "4419605",
        "facebookeventid": "",
        "eventname": "Mervi"
        "dates": {
            "startdate": "20120529010000",
            "enddate": "20121231235500",
            "timezone": "EDT"
        },
        "venue": {
            "venueid": "210795",
            "name": "On
            "venueimages": {
                "large": "",
                "small": ""
            }
        },
        "eventimages": [""],
        "prices": {
            "pricelow": "$195.00",
            "pricehigh": "$195.00",
            "pricedisplay": "$195.00"
        },
        "attractionList": [
            {
                "sequence": "0",
                "artist": "",
                "artistid": "7014411",
                "billing": "1.00",
                "genre": "Seminar/Lecture",
                "links": "",
                "media": ""
            },
            {
                "sequence": "1",
                "artist": "Families.",
                "artistid": "7014441",
                "billing": "0.75",
                "links": "",
                "media": ""
            },
            {
                "sequence": "2",
                "artist": "Se",
                "artistid": "7014451",
                "billing": "0.75",
                "links": "",
                "media": ""
            }
        ]
    },
我可以访问eventname和以下键条目以在 html 中生成值(这是我所追求的)但是当我想显示该venueid值时,这是在venue数组内部的哪个内部。并且eventimages它有一个空数组,它也在主数组内。在这里显示数据的正确语法是什么?我是否使用正确的 JSON/AJAX 方法来显示像这样的复杂 JSON 结构?谢谢。