Close #18264: int- and float-derived enums now converted to int or float.

This commit is contained in:
Ethan Furman 2013-08-10 13:01:45 -07:00
parent fbcf4d78c8
commit a4998a7041
4 changed files with 178 additions and 32 deletions

View file

@ -349,23 +349,26 @@ Encoders and Decoders
.. _py-to-json-table:
+-------------------+---------------+
| Python | JSON |
+===================+===============+
| dict | object |
+-------------------+---------------+
| list, tuple | array |
+-------------------+---------------+
| str | string |
+-------------------+---------------+
| int, float | number |
+-------------------+---------------+
| True | true |
+-------------------+---------------+
| False | false |
+-------------------+---------------+
| None | null |
+-------------------+---------------+
+----------------------------------------+---------------+
| Python | JSON |
+========================================+===============+
| dict | object |
+----------------------------------------+---------------+
| list, tuple | array |
+----------------------------------------+---------------+
| str | string |
+----------------------------------------+---------------+
| int, float, int- & float-derived Enums | number |
+----------------------------------------+---------------+
| True | true |
+----------------------------------------+---------------+
| False | false |
+----------------------------------------+---------------+
| None | null |
+----------------------------------------+---------------+
.. versionchanged:: 3.4
Added support for int- and float-derived Enum classes.
To extend this to recognize other objects, subclass and implement a
:meth:`default` method with another method that returns a serializable object