`jp.parent(o, failingPath)` throws meaningless error
Phrogz opened this issue · comments
const jp = require('jsonpath')
let o = {a:1}
console.log(jp.parent(o, '$.a'))
// { a: 1 }
jp.parent(o, '$.DOESNOTEXIST')
// Uncaught TypeError: Cannot read properties of undefined (reading 'path')
// at JSONPath.parent (./node_modules/jsonpath/lib/index.js:26:18)
- I expected this to work, since the parent does exist. (I expected the parser of the expression to drop the final term and resolve the path, instead of resolving the path and then backing up one.)
- If I did
jp.parent({}, '$.foo.bar.jim.jam')
I would expect it to returnnull
, or an empty array, not to error out on some internal code.