jsonpath icon indicating copy to clipboard operation
jsonpath copied to clipboard

Does path need to start with '$'?

Open shaunc opened this issue 9 years ago • 0 comments

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.

shaunc avatar Apr 24 '17 04:04 shaunc