jsonpath
jsonpath copied to clipboard
Does path need to start with '$'?
const x = {a: 1};
jp.query(x, 'a')
// returns 1
jp.value(x, 'a', 2);
// returns 2, sets key 'a' to 2 in x
jp.value(x, 'b', 2);
// Error: couldn't understand path
jp.query(x, 'b')
// returns []
jp.value(x, '$..b', 2);
// returns 2 and sets key 'b' to 2 in x
I would prefer to be able to leave the '$' off -- which mostly works -- as it seems redundant. But it seems to be necessary using "value" if the location does not yet exist.