[Python-ideas] Mimetypes Include application/json
Nate.
e4r7hbug at gmail.com
Wed Aug 9 14:50:47 EDT 2017
O, fun! Thank you for the guidance. I managed to find a Bug already
created, http://bugs.python.org/issue30824. I'll create a Pull Request
using that Bug.
On Wed, Aug 9, 2017 at 1:18 PM Brett Cannon <brett at python.org> wrote:
> On Wed, 9 Aug 2017 at 10:43 Nate. <e4r7hbug at gmail.com> wrote:
>
>> Hi,
>>
>> A friend and I have hit a funny situation with the `mimetypes.py` library
>> guessing the type for a '.json' file. Is there a reason why '.json'
>> hasn't been
>> added to the mapping?
>>
>
> Probably no one thought about it since the module was added in 1997 which
> is only 2 years after the creation of JavaScript itself. :)
>
>
>>
>> Without `mailcap` installed:
>>
>> [root at de169da8cc46 /]# python3 -m mimetypes build.json
>> I don't know anything about type build.json
>>
>> With `mailcap` installed:
>>
>> [root at de169da8cc46 /]# python3 -m mimetypes build.json
>> type: application/json encoding: None
>>
>> We experimented with adding a mapping for '.json' to 'application/json' to
>> `mimetypes.py` and it seems to work fine for us. It looks like it has been
>> registered with IANA and everything.
>>
>> Proposed diff:
>>
>> ntangsurat at derigible ~/git/e4r7hbug.cpython/Lib master $ git diff
>> diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
>> index 3d68694864..5919b45a9b 100644
>> --- a/Lib/mimetypes.py
>> +++ b/Lib/mimetypes.py
>> @@ -439,6 +439,7 @@ def _default_mime_types():
>> '.jpeg' : 'image/jpeg',
>> '.jpg' : 'image/jpeg',
>> '.js' : 'application/javascript',
>> + '.json' : 'application/json',
>> '.ksh' : 'text/plain',
>> '.latex' : 'application/x-latex',
>> '.m1v' : 'video/mpeg',
>>
>
> Feel free to file a bug at bugs.python.org and if you aren't too bothered
> then submit a PR to github.com/python/cpython (
> https://devguide.python.org/ has all the details).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170809/ba7bf30e/attachment-0001.html>
More information about the Python-ideas
mailing list