Request: Minify JSON. lolwut
I know it might sound weird, but if CodeKit had a minifier for JSON that would be neat. There aren't a lot of reasons to have this, but I can think of a few.
- For public static files, it reduces file size - and who doesn't want to do that?
- It would be neat if it could filter out comments. I know it's not valid to have comments in JSON but if the minification strips it out... no problem!
- It would be REALLY neat to have a pre-compiler for json so that you can use variables and stuff. Maybe something like this already exists and I'm just not aware of it.
There is a json minifier for npm, btw... so I know I'm not the only one who has found it useful.
EDIT: if it's not obvious already, it would be useful to have a source and a minified version of a JSON file - obviously otherwise you can never edit the original in its awesome formatted and commented form.
An interesting idea. I don't need Node stuff to do that; there's a C api that will be orders of magnitude faster than anything written in JavaScript could ever hope to be.
However, suppose you have myfile.json in your project. How is the app supposed to construct the output path? myfile-min.json? Is the file supposed to be minified in-place?
The Node example was just for reference and to show that others have found it to be useful. That minifier actually doesn't strip out comments, so that sucks.
I'd like to treat json files the same way CK2 treats js files I guess.
In my project, I have a 'src' dir and a 'public' dir. All of my 'src' files compile to 'public' - json would be the same, ideally.
But I realize some people like to have their .min files right next to their .whatever files so having both options like you do for js seems like a good idea.
EDIT: having it minified in-place would probably be bad news bears because then you'd never be able to make use of the comments or formatting of the original file.
@bdkjones Hey Bryan! I could definitely see a use for this!
I think there should be an option to either place the minified file in a /public directory or in-place with .min.json tacked on
Alright; I'll move it up my list. Shouldn't be too hard to implement.
:+1: awesome
+++1 for JSON minification. I'm working on a project right now and I'm butting my head up against not being able to minify the JSON file. I changed the filename from .json to .js, but uglify.js is still failing on the minification step.
@tlee1271: While @bdkjones is working on this, you can use other things that can do this for you pretty easily outside of CodeKit. I use json-minify for now. It won't allow comments and it won't do it automagically but it works.
Implemented for 2.2.1. Should be out this week; just waiting on Libsass to take 3.2 gold.
To be clear, though: comments aren't supported and the input JSON files have to be valid JSON. But CodeKit will minify them for you and will offer the ability to alphabetize dictionary items by key, which is very handy if your JSON file has to be committed to a repo. Per spec, there is no order to dictionary items in a JSON file.
Thanks so much! This is gonna be **awesome**.
You the man @bdkjones thanks!
@bdkjones I just wanted to thank you again for adding this feature. It auto-detects when I make changes and refreshes. It's fan-fucking beautiful. It's precisely what I was looking for! So stoked. You do good work man.
Sure thing!