我有以下 JSON 回复,我只想解析 4 个“整理”结果:
jQuery191029421305245357143_1380819227858(
{
"responseHeader": {
"status": 0,
"QTime": 127
},
"command": "build",
"spellcheck": {
"suggestions": [
"restaurant",
{
"numFound": 1,
"startOffset": 0,
"endOffset": 10,
"suggestion": [
"restaurants"
]
},
"berl",
{
"numFound": 4,
"startOffset": 11,
"endOffset": 15,
"suggestion": [
"berlin",
"berlin brandenburg",
"berlin hamburg",
"berliner"
]
},
"collation",
"restaurant berlin",
"collation",
"restaurant (berlin brandenburg)",
"collation",
"restaurants berlin",
"collation",
"restaurant (berlin hamburg)"
]
}
}
)
我得到以下结果:
"restaurant"
"berl"
"restaurant berlin"
"restaurant (berlin brandenburg)"
"restaurants berlin"
"restaurant (berlin hamburg)"
和
success: function( data ) {
response( $.map(data.spellcheck.suggestions, function(item) {
if (typeof item != "string") return;
if (item === "collation") return;
return item;
}));
问题:我怎样才能只得到这 4 个结果:
"restaurant berlin"
"restaurant (berlin brandenburg)"
"restaurants berlin"
"restaurant (berlin hamburg)"
没有两个(错误的)输入结果(“restaurants”+“berl”)?
谢谢!