|
1 | | -import json |
2 | 1 | from datetime import datetime |
3 | 2 | from datetime import timedelta |
4 | 3 | from datetime import timezone |
5 | | -from typing import Any |
6 | 4 | from typing import Iterable |
7 | 5 | from typing import List |
8 | 6 | from typing import Optional |
|
11 | 9 | from typing import Union |
12 | 10 |
|
13 | 11 | from flask import current_app |
14 | | -from flask.json.provider import _default |
15 | 12 | from jwt.algorithms import requires_cryptography |
16 | 13 |
|
| 14 | +from flask_jwt_extended.json_encoder import JSONEncoder |
17 | 15 | from flask_jwt_extended.typing import ExpiresDelta |
18 | 16 |
|
19 | 17 |
|
20 | | -class JSONEncoder(json.JSONEncoder): |
21 | | - """The default JSON encoder. Handles extra types compared to the |
22 | | - built-in :class:`json.JSONEncoder`. |
23 | | -
|
24 | | - - :class:`datetime.datetime` and :class:`datetime.date` are |
25 | | - serialized to :rfc:`822` strings. This is the same as the HTTP |
26 | | - date format. |
27 | | - - :class:`decimal.Decimal` is serialized to a string. |
28 | | - - :class:`uuid.UUID` is serialized to a string. |
29 | | - - :class:`dataclasses.dataclass` is passed to |
30 | | - :func:`dataclasses.asdict`. |
31 | | - - :class:`~markupsafe.Markup` (or any object with a ``__html__`` |
32 | | - method) will call the ``__html__`` method to get a string. |
33 | | -
|
34 | | - """ |
35 | | - |
36 | | - def default(self, o: Any) -> Any: |
37 | | - """Convert ``o`` to a JSON serializable type. See |
38 | | - :meth:`json.JSONEncoder.default`. Python does not support |
39 | | - overriding how basic types like ``str`` or ``list`` are |
40 | | - serialized, they are handled before this method. |
41 | | - """ |
42 | | - return _default(o) |
43 | | - |
44 | | - |
45 | 18 | class _Config(object): |
46 | 19 | """ |
47 | 20 | Helper object for accessing and verifying options in this extension. This |
|
0 commit comments