2010-12-23 2 views
0

에서 객체 데이터를 인쇄하는 방법은 다음과 같은 개체 데이터가 있습니다자바 스크립트

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

내가 "target"을 인쇄 할 response.response.docs[0].description을 사용할 수 있습니다. 하지만 "<em>target</em>"을 출력하는 방법을 모르겠습니다. 감사.

+0

질문을 명확히하십시오. "목표"를 인쇄 할 수는 있지만 "목표"를 인쇄하는 방법을 모른다고하셨습니까? – Kyle

+0

문제는 해결하기에 충분히 명확하지 않습니다. – Varun

답변

0

를 [0] 또는 중 다른 객체 참조 문서에 대한 참조를 유지할 필요가 가정 :

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