Improved JSON mime type regular expression.

Also exposed the regular expression in the API so it can be used (e.g.: for
testing) and overridden through options.  Also added tests.