-
Notifications
You must be signed in to change notification settings - Fork 58
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
json2csv doesn't flatten values correctly #184
Comments
Thanks for reporting this @joshuali925. This wasn't a scenario I considered, but it's definitely valid. It looks like I'll need to rework things a bit in both the underlying key path generation module ( |
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
This module did not previously offer a way to encode any nested '.' characters in a key such that it could be easily identified for use by the end user or other modules. As a result, any keys which had nested '.' characters appeared as though they were simply another nested object layer, but this could cause issues if trying to reconstruct the object. This commit adds the escapeNestedDots option which allows the user to optionally specify that this information should be encoded for later use by the consuming software. Related to mrodrig/json-2-csv#184
Through modifications to `doc-path` and `deeks` dependency underlying code, I've worked to add support for the keys with nested dots in the JSON key path and conversion back to CSV. This was achieved through the `deeks` module's new `escapeNestedDots` option which will now be set to `true`. Additionally, support for this escaping was added to `doc-path` so that the correct values are retrieved and can also be correctly set for csv2json. This commit adds the option specification for the `deeks` module, and once the dependency modules are released, another commit will be pushed which will update the dependency module versions to the newest releases which add support. Fixes #184
This module did not previously offer a way to encode any nested '.' characters in a key such that it could be easily identified for use by the end user or other modules. As a result, any keys which had nested '.' characters appeared as though they were simply another nested object layer, but this could cause issues if trying to reconstruct the object. This commit adds the escapeNestedDots option which allows the user to optionally specify that this information should be encoded for later use by the consuming software. Related to mrodrig/json-2-csv#184
* chore(release): 2.4.0 * Add escapeNestedDots option for preserving key structure. (#17) This module did not previously offer a way to encode any nested '.' characters in a key such that it could be easily identified for use by the end user or other modules. As a result, any keys which had nested '.' characters appeared as though they were simply another nested object layer, but this could cause issues if trying to reconstruct the object. This commit adds the escapeNestedDots option which allows the user to optionally specify that this information should be encoded for later use by the consuming software. Related to mrodrig/json-2-csv#184
* Add support for paths with escaped dots in path. 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 * Infrastructure updates - node test, es version * chore(release): 3.0.0 * Remove logic for unreachable condition * Update README
Through modifications to `doc-path` and `deeks` dependency underlying code, I've worked to add support for the keys with nested dots in the JSON key path and conversion back to CSV. This was achieved through the `deeks` module's new `escapeNestedDots` option which will now be set to `true`. Additionally, support for this escaping was added to `doc-path` so that the correct values are retrieved and can also be correctly set for csv2json. This commit adds the option specification for the `deeks` module and the updated versions of the dependency modules in package.json. Fixes #184
Just wanted to give a quick update - I have the needed changes in the |
Got it, thanks a lot for your work! |
* Add support for keys with nested dots. Through modifications to `doc-path` and `deeks` dependency underlying code, I've worked to add support for the keys with nested dots in the JSON key path and conversion back to CSV. This was achieved through the `deeks` module's new `escapeNestedDots` option which will now be set to `true`. Additionally, support for this escaping was added to `doc-path` so that the correct values are retrieved and can also be correctly set for csv2json. This commit adds the option specification for the `deeks` module and the updated versions of the dependency modules in package.json. Fixes #184
I just merged and published the fix in |
Background Information
3.11.1
10.23.1
The issue I'm reporting is with:
I have...
Expected Behavior
outputs values
Actual Behavior
outputs null
Data Sample
CSV:
(or)
JSON:
Code Example
The text was updated successfully, but these errors were encountered: