mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Close #18264: int- and float-derived enums now converted to int or float.
This commit is contained in:
parent
fbcf4d78c8
commit
a4998a7041
4 changed files with 178 additions and 32 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue