我有以下json:
{
"responseHeader": {
"status": 0,
"QTime": 1
},
"spellcheck": {
"suggestions": [
"a",
{
"numFound": 4,
"startOffset": 0,
"endOffset": 1,
"suggestion": [
"api",
"and",
"as",
"an"
]
},
"collation",
"api"
]
}
}
我想访问“建议”数组,为此我在 jQuery 中使用它:
$.getJSON('http://localhost:8983/solr/suggest/?q=' + query + '&wt=json&json.wrf=?', {
})
.done(function(response){
// just for testing
alert(response.spellcheck.suggestions.suggestion); // error: response.spellcheck is not defined
});
“response.spellcheck”的值显示为未定义,而“response.responseHeader”显示[object Object],而且我可以访问responseHeader下的元素。但我无法弄清楚“拼写检查”有什么问题。帮助!