2010-12-23 25 views
0

打印對象的數據,我有以下對象的數據:如何在JavaScript

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>"。謝謝。

+0

請澄清你的問題。你說你可以打印「目標」,但你不知道如何打印「目標」? – Kyle 2010-12-23 04:36:47

回答

0

假設你需要保持引用文檔[0]或任何其他對象的引用:

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