Improve CJSON readability while maintaining size #5
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.
Some CJSON files are formatted with consistent indentation of generally two spaces, but this makes them very long and hard to scan through (because each array is spread over as many lines as it has items). This is also inefficient from a space perspective. Even something as simple as acetone, for example, looks like:
Some CJSON files have no indentation at all, with all the data on a single line. This results in an extremely long line length, which some editors complain about, and is extremely unreadable. It is at least space efficient. For acetone:
I wrote a short Python script which takes a middle route: indentation, but arrays of simple values (no nested arrays or objects) are flattened and printed on a single line. The result for acetone:
Crucially, this doesn't really increase the size of the repo (unlike universal indentation) --
fragments
goes down in size by 0.3 MiB, whilemolecules
increases by 0.2 MiB.