diff --git a/jpath.js b/jpath.js index c0d772f..7aa1f08 100644 --- a/jpath.js +++ b/jpath.js @@ -413,7 +413,7 @@ var executors = { return json; } - if (typeof json === 'object') { + if (typeof json === 'object' && json !== null) { // в массиве нужно выполнить шаг для каждого элемента if (isArray(json)) { var arr = []; diff --git a/test/spec/jpath.js b/test/spec/jpath.js index 4b4bfdc..d1ecab9 100644 --- a/test/spec/jpath.js +++ b/test/spec/jpath.js @@ -240,6 +240,10 @@ describe('jpath', function() { expect(jpath(json, '.c[.nu].d.e')).to.eql([]); }); + it('.c.nu.d.e -', function() { + expect(jpath(json, '.c.nu.d.e')).to.eql([]); + }); + it('.c[.ea].d.e -', function() { expect(jpath(json, '.c[.nu].d.e')).to.eql([]); });