我有以下形式的 json 响应:
[{
"id": 425055,
"title": "Foo"
}, {
"id": 425038,
"title": "Bar"
}, {
"id": 425015,
"title": "Narf"
}]
我使用 oboe.js 创建一个高地流:
const cruiseNidStream = _((push, next) => {
oboe({
url: 'http://fake.com/bar/overview,
method: 'GET',
headers: {
'X-AUTH': 'some token',
},
}).node('.*', (overview) => {
// I expect here to get an object having and id, title property
push(null, overview.id);
}).done((overview) => {
push(null, _.nil);
}).fail((reason) => {
console.error(reason);
push(null, _.nil);
});
});
我的问题是我不知道使用什么模式 node 以便它匹配该数组的每个元素。目前,我通过当前设置获得的项目是所有对象和属性:
425055
Foo
{ id: 227709, title: 'Foo' }
如果响应将具有如下属性:
{
'overview': [],
}
我本来可以用.overview.*
.