简体   繁体   English

如何在JavaScript中打印对象数据

[英]How to print object data in javascript

I have the following object data: 我有以下对象数据:

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"]
        }
    }
};

I can use response.response.docs[0].description to print out "target" . 我可以使用response.response.docs[0].description来打印"target" But I don't know how to print out "<em>target</em>" . 但是我不知道如何打印"<em>target</em>" Thanks. 谢谢。

response.highlighting[269653].description[0]

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

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM