jmespath.js
jmespath.js copied to clipboard
failed when the field key with dot
var jmespath = require('jmespath');
const data = {
foo: {'bar.baff': {baz: [0, 1, 2, 3, 4]}},
b: 2323
}
const result = jmespath.search(data, 'foo["bar.baff"]');
console.log(result);
show errors:
/node_modules/[email protected]@jmespath/jmespath.js:705
throw error;
^
ParserError: Expected Star, got: QuotedIdentifier
at Parser._match (/Users/hufanee/Github/purejs/node_modules/[email protected]@jmespath/jmespath.js:703:27)
at Parser.led (/Users/hufanee/Github/purejs/node_modules/[email protected]@jmespath/jmespath.js:687:22)
at Parser.expression (/Users/hufanee/Github/purejs/node_modules/[email protected]@jmespath/jmespath.js:523:27)
at Parser.parse (/Users/hufanee/Github/purejs/node_modules/[email protected]@jmespath/jmespath.js:498:26)
at Object.search (/Users/hufanee/Github/purejs/node_modules/[email protected]@jmespath/jmespath.js:1659:25)
at Object.<anonymous> (/Users/hufanee/Github/purejs/tempCodeRunnerFile.js:6:25)
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
const result = jmespath.search(data, 'foo."bar.baff"');
sorry, this will work.
Will this work? const result = jmespath.search(data, 'foo[`"bar.baff"`]');