Javascript 在对象中打印对象

Javascript 在对象中打印对象,javascript,object,Javascript,Object,你好,也许是个愚蠢的问题,但我如何打印,例如,从这个开始 var text = { "responseData": { "results": [ { "GsearchResultClass": "GwebSearch", "unescapedUrl": "http://dojotoolkit.org/", "url": "http://dojotoolkit.org/", "v

你好,也许是个愚蠢的问题,但我如何打印,例如,从这个开始

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

谢谢

在chrome控制台中粘贴此
文本
json对象。并尝试访问
文本
变量。它将自动完成,并帮助您找到所需的变量内对象的路径。这就是我对json对象所做的。对于
start
变量,请尝试以下代码

var pages = text.responseData.cursor.pages;
for(var i=0; i < pages.length; i++){
   console.log(pages[i].start)
}  
var pages=text.responseData.cursor.pages;
对于(变量i=0;i
要输出哪个
开始
?显示您期望的输出。例如,使用值0使用
console.log(text.responseData['results'])
如果希望访问0
text.responseData.cursor.pages[0]的起始值,我猜您的意思是这样的
var pages = text.responseData.cursor.pages;
for(var i=0; i < pages.length; i++){
   console.log(pages[i].start)
}