Properly format normalized path names #113
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The RFC defines how to format normalized path names. Notably, it defines the escape character as
ESC normal-escapable
, but doesn't defineESC
in that section. It is, however, defined for name selector syntax as%x5C; \ backslash
. I'm therefore reasonably sure that the current behavior of serde_json_path when formatting normalized paths is incorrect, as it results in no escaping of'
at all.For example, using the sandbox to select
$.*
from{"O'Reilly": true}
returnsI worked this out while building the location feature into Go jsonpath (many thanks for the inspiration in your crate!). This playground link shows what I believe to be the correct escaping (doubled for inclusion in JSON):
So expand
Display for PathElement
to properly format characters strictly according to the spec. Iterate over each character in a name and escape exactly the characters it defines to be escaped.