Implementation ignores trailing /
Closed this issue · 2 comments
SquareByte commented
Error example:
const data = {
"": "<<empty",
"key": "value"
};
jsonPointer.get(data, "/"); // yields "<<empty", OK
jsonPointer.get(data, "//"); // yields "<<empty", error!
jsonPointer.get(data, "/key/"); // yields "value", error!Implementation correctly returns values for empty string keys. But according to spec and the docs, I would expect to get undefined in both latter cases, as the corresponding object {"":{"":...}} is not in the data.
sagold commented
Hi SquareByte,
thank you for this issue. You are right, trailing slashes are removed before retrieving any path, selecting empty properties is not supported. I might change this with version 6 as this will introduce a breaking change. Will need to do some investigations first.
sagold commented
Hi SquareByte,
support for empty property names has been added and is published with @sagold/json-pointer@v6.0.0
Cheers!