-
Notifications
You must be signed in to change notification settings - Fork 136
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
ChoETL.json converting JSON with string arrays to CSV files then cannot be restored to the original JSON #263
Comments
put together sample fiddle, take a look at it. Let me know. https://dotnetfiddle.net/Yk2pvT FYI, pls take the latest version. |
Thanks for the answer, this is useful, but it's not a generic method, it requires me to have to know the field names of the array. |
Well, as the csv can't capture the state of the empty (WIP_CODE) array. no way for the json parser reconstruct it back to empty array. Hence you need to explicitly tell it to create one as empty. |
@Cinchoo |
Here is how you can convert csv back to expected json. https://dotnetfiddle.net/kEyFwo PS: this feature (nullvaluehandling) will be added to framework in future. |
If I have a json string like this:
{ "BATCH_CODE": ["1", "2"] "WIP_CODE":[] }
When I use code
using (var r = new ChoJSONReader(str)) { using (var w = new ChoCSVWriter(path).Configure(c => c.NestedColumnSeparator = '/').WithFirstLineHeader()) { w.Write(r); } }
In CSV file column it will be
Then I want to convert the csv file back to the original json and find that it cannot be restored,but it failed
using (var w = new ChoJSONWriter(json) .Configure(c => c.DefaultArrayHandling = false) ) { using (var r = new ChoCSVReader(str).WithFirstLineHeader() .Configure(c => c.ArrayIndexSeparator = '/') ) w.Write(r); }
it will be
{ "BATCH_CODE": { "0": "1", "1": "2" } }
Can you help me?
The text was updated successfully, but these errors were encountered: