Closed
Conversation
Adds the --in-place command line option to save back edits to the input file without needing to name all the input files twice using --output. We had to restructure the CLI file flow quite a bit because we don't want to touch the output file if running in-place and if the contents haven't changed. (And because argparse.FileType is now deprecated.) To prove that the file hasn't changed we keep the input string around, but this will cost considerable memory for large files. Potential alternatives would be to SHA the file contents at the cost of computation cycles and the small risk of collision, or to write out to a temporary file and do the compare before swapping.
Owner
|
I am now waiting on the outcome of j-brooke/FracturedJson#48 But assuming that the .NET version goes ahead, I'll replicate the command-line with these improvements. |
Owner
|
I've implemented this in https://pypi.org/project/fractured-json/ since that's the future for how this JSON compactor will work. .NET runtime is big but easily installed so I think it's a fair compromise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds the --in-place command line option to save back edits to the input file without needing to name all the input files twice using --output.
We had to restructure the CLI file flow quite a bit because we don't want to touch the output file if running in-place and if the contents haven't changed. (And because argparse.FileType is now deprecated.)