I have a json response in the form of:
[{
"id": 425055,
"title": "Foo"
}, {
"id": 425038,
"title": "Bar"
}, {
"id": 425015,
"title": "Narf"
}]
I use oboe.js to create a highland stream:
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);
});
});
My problem is that I don't know what pattern to use node so that it matches each element of that array. As currently the items I am getting with the current setup are all the objects and the properties again:
425055
Foo
{ id: 227709, title: 'Foo' }
If the response would have had a property like:
{
'overview': [],
}
I could have used .overview.*.
Oboe has two ways of matching data, by path and by duck-typing.
By duck-typing
By path
In the path example, notice the
!character. This refers to the root node of the tree, this pattern will only your three objects, not any of their own properties nested further down.I made a gomix where you can view this working in the console, and also view the source.