json-source-map
json-source-map copied to clipboard
support arbitrary keys
now users must append jsonMap.leaf_node
to their keyList
like
const jsonMap = require('json-source-map');
const result = jsonMap.parse('{"z":1,"a":{"z":1,"a":1}}');
const keyList = ['z', 'a']; // before this was ptr = '/z/a'
let pointer = result.pointers;
for (let key of keyList.concat([jsonMap.leaf_key])) {
pointer = pointer[key];
}
const [a, b] = [pointer.value.pos, pointer.valueEnd.pos];
edit: forgot keyList = ....
in commit message
edit: the constant should not be called leaf_key
, rather loc_key
todo: tests ....