Skip to content
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

Omit whitespace when generating JSON artefacts #4983

Merged
merged 1 commit into from
Sep 1, 2020
Merged

Conversation

Alhadis
Copy link
Collaborator

@Alhadis Alhadis commented Sep 1, 2020

I'm not sure why Linguist ships with "pretty"-printed JSON files (shock quotes used, because 2-space indents are NOT pretty). If whitespace is omitted, several megabytes are shaved off the (unpacked) JSON files:

linguist-grammars.tar.gz (unpacked)  12 MBs  => 8.3 MBs
lib/linguist/samples.json            4.3 MBs => 2.7 MBs

These files aren't intended for human consumption, so I've no idea why they're being generated that way on purpose. If somebody does need to browse their contents, reformatting JSON is trivial to do in anything with a JavaScript engine attached:

JSON.stringify(JSON.parse(jsonSourceCode), null, "\t");

// Or if you like to pretend an arbitrarily-long bunch of spaces is a tab:

JSON.stringify(JSON.parse(jsonSourceCode), null, pickHowManySpacesYouLikeSweetheart);

Template removed as it doesn't apply.

@Alhadis Alhadis requested a review from lildude September 1, 2020 01:29
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why either, but the saving is pretty impressive and I know the GitHub.com dev peeps will be happy with this. Thanks.

@lildude lildude merged commit 7d6b3f2 into master Sep 1, 2020
@lildude lildude deleted the compress-json branch September 1, 2020 09:26
sambacha pushed a commit to freight-trust/linguist that referenced this pull request Sep 4, 2020
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants