1 | var jpath = require('..')
|
2 | , expect = require('expect.js')
|
3 | , data = require('./example-data')
|
4 |
|
5 | var p = jpath.create("#/store/book[*][@]");
|
6 |
|
7 | var res = p.resolve(data, function(obj, accum) {
|
8 | if (typeof obj.price === 'number' && obj.price < 10)
|
9 | accum.push(obj);
|
10 | return accum;
|
11 | });
|
12 |
|
13 | // Expect the result to have the two books priced under $10...
|
14 | expect(res).to.contain(data["store"]["book"][0]);
|
15 | expect(res).to.contain(data["store"]["book"][2]);
|
16 | expect(res).to.have.length(2);
|