我有以下代码来检索json响应。我需要提取属性'申请人'并将其放到html文本字段中。但是我不知道怎么做。我可以在控制台中看到响应,但文本字段显示[object Object],如何将其检索到文本字段?任何提示?谢谢。
<html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
document.getElementById('sudata').value = budata;
}
});
</script>
</head>
<body>
<form name="form1" id="form1">
<input type="text" name="sudata" id="sudata" value="" size="100">
</form>
</body>
</html>
回复在这里:
{"ops:world-patent-data": {
"@xmlns": {
"ops": "http://ops.epo.org",
"$": "http://www.epo.org/exchange",
"ccd": "http://www.epo.org/ccd",
"xlink": "http://www.w3.org/1999/xlink"
},
"ops:meta": {
"@name": "elapsed-time",
"@value": "31"
},
"exchange-documents": {"exchange-document": {
"@system": "ops.epo.org",
"@family-id": "35636806",
"@country": "EP",
"@doc-number": "1814517",
"@kind": "A1",
"bibliographic-data": {
"publication-reference": {"document-id": [
{
"@document-id-type": "docdb",
"country": {"$": "EP"},
"doc-number": {"$": "1814517"},
"kind": {"$": "A1"},
"date": {"$": "20070808"}
},
{
"@document-id-type": "epodoc",
"doc-number": {"$": "EP1814517"},
"date": {"$": "20070808"}
}
]},
"classifications-ipcr": {"classification-ipcr": [
{
"@sequence": "1",
"text": {"$": "A61K 9/ 08 A I"}
},
{
"@sequence": "2",
"text": {"$": "A61K 31/ 19 A I"}
},
{
"@sequence": "3",
"text": {"$": "A61K 31/ 216 A I"}
},
{
"@sequence": "4",
"text": {"$": "A61K 47/ 00 A I"}
},
{
"@sequence": "5",
"text": {"$": "C07C 57/ 38 A I"}
},
{
"@sequence": "6",
"text": {"$": "C07C 229/ 42 A I"}
}
]},
"patent-classifications": {"patent-classification": [
{
"@sequence": "1",
"classification-scheme": {
"@office": "EP",
"@scheme": "EC"
},
"classification-symbol": {"$": "A61K9/00M5"}
},
{
"@sequence": "2",
"classification-scheme": {
"@office": "EP",
"@scheme": "EC"
},
"classification-symbol": {"$": "A61K31/19"}
},
{
"@sequence": "3",
"classification-scheme": {
"@office": "EP",
"@scheme": "EC"
},
"classification-symbol": {"$": "A61K31/216"}
}
]},
"application-reference": {
"@doc-id": "16272416",
"document-id": [
{
"@document-id-type": "docdb",
"country": {"$": "EP"},
"doc-number": {"$": "05808069"},
"kind": {"$": "A"}
},
{
"@document-id-type": "epodoc",
"doc-number": {"$": "EP20050808069"},
"date": {"$": "20051019"}
},
{
"@document-id-type": "original",
"doc-number": {"$": "05808069"}
}
]
},
"priority-claims": {"priority-claim": [
{
"@sequence": "1",
"@kind": "national",
"document-id": [
{
"@document-id-type": "epodoc",
"doc-number": {"$": "WO2005IN00339"},
"date": {"$": "20051019"}
},
{
"@document-id-type": "original",
"doc-number": {"$": "IN2005000339"}
}
]
},
{
"@sequence": "2",
"@kind": "national",
"document-id": [
{
"@document-id-type": "epodoc",
"doc-number": {"$": "IN2004DE02332"},
"date": {"$": "20041122"}
},
{
"@document-id-type": "original",
"doc-number": {"$": "DE23322004"}
}
]
}
]},
"parties": {
"applicants": {"applicant": [
{
"@sequence": "1",
"@data-format": "epodoc",
"applicant-name": {"name": {"$": "VENUS REMEDIES LTD [IN]"}}
},
{
"@sequence": "1",
"@data-format": "original",
"applicant-name": {"name": {"$": "VENUS REMEDIES LIMITED"}}
答案 0 :(得分:0)
您的budata
变量包含一个数组。元素的value
属性是一个字符串属性,因此当您为其指定一个对象时,该对象首先使用Object :: toString()进行转换;这将返回[object Object]
。
如果您要显示申请人财产的全部内容,请尝试:
document.getElementById( 'sudata' ).value = JSON.stringify( budata );
如果您只是尝试显示数组的特定部分,则必须指定预期的输出字符串。