Pass default parser to custom parse value function #218
+17
−4
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.
Background Information
3.17
I have...
Hi @mrodrig,
I'm experimenting with using json-2-csv in a project I'm working on and have a use case where I'd like to custom parse some field values but use default parsing for the others. It seems that custom parsing is currently all or nothing, that is, if you provide a
parseValue
function it has to handle all field values. I thought the least disruptive way to enable custom parsing on a value-by-value basis would be to provide access to the built-in parser within the custom parser function so that's what I've done with this PR. The intention is to enable "ejecting" from custom parsing by returning the result of the default parser. For example,I considered supplying custom parsers for individual fields as part of the
keys
array (and liked that idea) but felt that this was, again, a less disruptive step in that direction. Happy to hear your feedback/thoughts/suggestions. Thanks for your work on json-2-csv.