0

こんにちは、ばかげた質問かもしれませんが、たとえばこれから印刷するにはどうすればよいですか

var text = {
"responseData": {
    "results": [
        {
            "GsearchResultClass": "GwebSearch",
            "unescapedUrl": "http://dojotoolkit.org/",
            "url": "http://dojotoolkit.org/",
            "visibleUrl": "dojotoolkit.org",
            "cacheUrl": "http://www.google.com/search?q=cache:sUiWYphwkaoJ:dojotoolkit.org",
            "title": "Unbeatable JavaScript Tools - The <b>Dojo Toolkit</b>",
            "titleNoFormatting": "Unbeatable JavaScript Tools - The Dojo Toolkit",
            "content": "<b>Dojo</b> saves you time, delivers powerful performance, and scales with your   development process. It&#39;s the <b>toolkit</b> experienced developers turn to for building <b>...</b>"
        },
        {
            "GsearchResultClass": "GwebSearch",
            "unescapedUrl": "http://dojotoolkit.org/download/",
            "url": "http://dojotoolkit.org/download/",
            "visibleUrl": "dojotoolkit.org",
            "cacheUrl": "http://www.google.com/search?q=cache:cQhx_NOJhyYJ:dojotoolkit.org",
            "title": "Download - The <b>Dojo Toolkit</b>",
            "titleNoFormatting": "Download - The Dojo Toolkit",
            "content": "This download is ideal for situations   where a custom build will not be   required."
        },
        {
            "GsearchResultClass": "GwebSearch",
            "unescapedUrl": "http://dojotoolkit.org/documentation/",
            "url": "http://dojotoolkit.org/documentation/",
            "visibleUrl": "dojotoolkit.org",
            "cacheUrl": "http://www.google.com/search?q=cache:ws95YbyVgxgJ:dojotoolkit.org",
            "title": "Documentation - The <b>Dojo Toolkit</b>",
            "titleNoFormatting": "Documentation - The Dojo Toolkit",
            "content": "How do I start learning Dojo? Where are   the docs? How do I get support and <b>...</b>"
        },
        {
            "GsearchResultClass": "GwebSearch",
            "unescapedUrl": "http://en.wikipedia.org/wiki/Dojo_Toolkit",
            "url": "http://en.wikipedia.org/wiki/Dojo_Toolkit",
            "visibleUrl": "en.wikipedia.org",
            "cacheUrl": "http://www.google.com/search?q=cache:6gxw4t2myDIJ:en.wikipedia.org",
            "title": "<b>Dojo Toolkit</b> - Wikipedia, the free encyclopedia",
            "titleNoFormatting": "Dojo Toolkit - Wikipedia, the free encyclopedia",
            "content": "<b>Dojo Toolkit</b> (stylized as dōjō toolkit) is an open source modular JavaScript library   (or more specifically JavaScript toolkit) designed to ease the rapid <b>...</b>"
        }
    ],
    "cursor": {
        "resultCount": "83,500",
        "pages": [
            {
                "start": "0",
                "label": 1
            },
            {
                "start": "4",
                "label": 2
            },
            {
                "start": "8",
                "label": 3
            },
            {
                "start": "12",
                "label": 4
            },
            {
                "start": "16",
                "label": 5
            },
            {
                "start": "20",
                "label": 6
            },
            {
                "start": "24",
                "label": 7
            },
            {
                "start": "28",
                "label": 8
            }
        ],
        "estimatedResultCount": "83500",
        "currentPageIndex": 0,
        "moreResultsUrl": "http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=dojo+toolkit",
        "searchResultTime": "0.20"
    }
},
"responseDetails": null,
"responseStatus": 200

}

オブジェクト内のオブジェクトへのアクセスに問題があります。情報を教えてください。

私は次のようなことをしたかった:

 alert(text.responseData['results'])

ありがとうございました

4

1 に答える 1

0

このtextjson オブジェクトを chrome のコンソールに貼り付けます。textそして、変数にアクセスしてみてください。オートコンプリートされ、変数内のオブジェクトへのパスを見つけるのに役立ちます。それが私がjsonオブジェクトに対して行うことです。変数については、startこのコードを試してください。

var pages = text.responseData.cursor.pages;
for(var i=0; i < pages.length; i++){
   console.log(pages[i].start)
}  
于 2013-10-03T08:56:38.320 に答える