如何从 Google 自定义搜索 API 解析 json 对象中的 "og:description" 节点

How to parse "og:description" node in json object from Google Custom Search API

我正在使用 Google 自定义搜索 API,它为我提供了 json 中的搜索结果。 (Docs)

我需要获取节点的内容og:description,但显然它并没有我想的那么简单。我试过使用这个:items.pagemap.metatags[0].og:description 这行不通 - 分号会导致错误。

我的其余代码如下所示并且正在运行:

    var key = "xxx";
    var cx = "xxx";
    var q = "cars";
    var url = "https://www.googleapis.com/customsearch/v1?q=" + encodeURIComponent(q) + " &prettyPrint=false&cx=" + cx + "&key=" + key + "";
    $.getJSON(url, function(data) {
        var news = [];
        if (data.items) {
            $.each(data.items, function(key, i) {
                news.push("<li><img src='" + i.pagemap.cse_image[0].src + "'><a target='_blank' href='" + i.link + "'>" + i.title + "</a><div class='description'>" + i.snippet + "</div></li>");
                //console.log(data);
            });
        }

        $("<ul/>", {
            html: news.join("")
        }).appendTo("#content_0");
    }).fail(function() {
        console.log("error");
    });

非常感谢任何帮助。

经过几个小时的搜索,结果证明解决方案是这样的 - 方括号:

items.pagemap.metatags[0]['og:description']