Skip to content
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

Add support for escaped paths. #20

Merged
merged 4 commits into from
May 26, 2021
Merged

Add support for escaped paths. #20

merged 4 commits into from
May 26, 2021

Conversation

mrodrig
Copy link
Owner

@mrodrig mrodrig commented May 24, 2021

There are valid JSON keys which can contain a nested '.' in them.
However, this module would not handle those properly, except in a
limited set of conditions. This commit adds support for these paths when
they are properly escaped using a '\' character. However, this does
slightly change the base functionality for the module where a value with
the same key path as a top-level key with the nested value's key path
will now read the nested value, unless the provided path has appropriate
escaping on the key path.

For example... with the example doc:
    { 'a.b' : 2, a : { b : 3 } }

evaluatePath(doc, 'a.b') will now return 3
    and
evaluatePath(doc, 'a\\.b') will now return 2

Related to mrodrig/json-2-csv#184
@mrodrig mrodrig changed the base branch from stable to 3.0.0 May 24, 2021 02:57
@mrodrig mrodrig merged commit 6924ef0 into 3.0.0 May 26, 2021
@mrodrig mrodrig deleted the fix-j2c-184 branch November 1, 2023 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant