The grunt config is javascript, not json. So you can write custom tasks code in your grunt config.
For instance, I wrote a custom tag to modify specific pages to inject javascript include statements in HTML pages. There is probably a plugin for that, but I was able to write the code in 15 minutes so I didn't care.