如何在javascript中打印对象数据

时间:2010-12-23 04:33:54

标签: javascript object

我有以下对象数据:

var response = {
    "response": {
        "numFound": 7945,
        "docs": [{
            "description": "target",
            "url": "target",
            "id": "269653",
            "score": 6.9186745
        },
        {
            "description": "Target Kent",
            "url": "Target_Kent",
            "id": "37275",
            "score": 4.3241715
        }]
    },
    "highlighting": {
        "269653": {
            "description": ["<em>target</em>"]
        },
        "37275": {
            "description": ["<em>Target</em> Kent"]
        }
    }
};

我可以使用response.response.docs[0].description打印"target"。但我不知道如何打印"<em>target</em>"。谢谢。

2 个答案:

答案 0 :(得分:1)

response.highlighting[269653].description[0]

试一试: http://jsfiddle.net/9QFAM/

答案 1 :(得分:0)

假设您需要保留对docs [0]或其他任何对象引用的引用:

response.highlighting[response.response.docs[0].id].description[0]