-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need better handling of JSON keys #4
Comments
Hi @Kit-p, You can have I think your suggestion of quotes probably would have been better but I think this should work properly as long as paths are correctly generated. Is this related to a JSON Hero issue? My guess would be that the JSON parser is not correctly encoding the paths with backslashes. |
@matt-aitken Thank you for the information! Indeed if the However, the one special case where an empty string is used as a key still causes a crash due to infinite recursion. I believe this issue should remain open. An ugly fix (so we don't need to change anything here) would be to use Edit: I tried implementing the ugly fix mentioned above, can't get it to work because if |
Scenario:
Description:
Since
"a.b"
is a valid key, the.
must be escaped before appending to the path, in order to not be confused with"a"."b"
. A more robust way of dealing with this issue would be to quote the key, as you can also have things like whitespace in the key, or even an empty string as key. A reference approach at https://jqplay.org/s/7sO6XJmPdTZ where I recreated the scenarios usingjq
.Code Reference:
https://github.com/apihero-run/json-hero-path/blob/b873f34546c3763b9c78987e504e86b34a295b9c/src/index.ts#L56
Possible Solution:
Related Issues:
None in this repository, but unfortunately caused one in triggerdotdev/jsonhero-web#98.
Feel free to let me know if there is a better way to solve this (or if my proposed solution will break something), otherwise I will start working on a PR.
The text was updated successfully, but these errors were encountered: