__init__.py — flask Source File
Architecture documentation for __init__.py, a python file in the flask codebase. 6 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR a2a0fafc_2ea9_1b29_60c7_bc4419008a44["__init__.py"] a8e4bac6_331b_dd63_b711_32605e8c7edc["globals"] a2a0fafc_2ea9_1b29_60c7_bc4419008a44 --> a8e4bac6_331b_dd63_b711_32605e8c7edc 64bf3a3f_ca45_015e_bd00_0190cbad6928["provider.py"] a2a0fafc_2ea9_1b29_60c7_bc4419008a44 --> 64bf3a3f_ca45_015e_bd00_0190cbad6928 495a78d7_26f1_1764_0f3e_4b0560d2f70d["_default"] a2a0fafc_2ea9_1b29_60c7_bc4419008a44 --> 495a78d7_26f1_1764_0f3e_4b0560d2f70d 2899c052_85d9_6642_19f1_ab960b34e824["wrappers"] a2a0fafc_2ea9_1b29_60c7_bc4419008a44 --> 2899c052_85d9_6642_19f1_ab960b34e824 24c75b54_2419_4c05_11fb_668c1d1c4ac5["json"] a2a0fafc_2ea9_1b29_60c7_bc4419008a44 --> 24c75b54_2419_4c05_11fb_668c1d1c4ac5 852dc50b_4da6_57dc_ead7_cdd90925e0b8["typing"] a2a0fafc_2ea9_1b29_60c7_bc4419008a44 --> 852dc50b_4da6_57dc_ead7_cdd90925e0b8 e1ae29a1_73d3_d5e9_3fd5_548f4ac50138["__init__.py"] e1ae29a1_73d3_d5e9_3fd5_548f4ac50138 --> a2a0fafc_2ea9_1b29_60c7_bc4419008a44 2e858a02_7725_54fd_8d55_a9c969ab89bf["config.py"] 2e858a02_7725_54fd_8d55_a9c969ab89bf --> a2a0fafc_2ea9_1b29_60c7_bc4419008a44 style a2a0fafc_2ea9_1b29_60c7_bc4419008a44 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from __future__ import annotations
import json as _json
import typing as t
from ..globals import current_app
from .provider import _default
if t.TYPE_CHECKING: # pragma: no cover
from ..wrappers import Response
def dumps(obj: t.Any, **kwargs: t.Any) -> str:
"""Serialize data as JSON.
If :data:`~flask.current_app` is available, it will use its
:meth:`app.json.dumps() <flask.json.provider.JSONProvider.dumps>`
method, otherwise it will use :func:`json.dumps`.
:param obj: The data to serialize.
:param kwargs: Arguments passed to the ``dumps`` implementation.
.. versionchanged:: 2.3
The ``app`` parameter was removed.
.. versionchanged:: 2.2
Calls ``current_app.json.dumps``, allowing an app to override
the behavior.
.. versionchanged:: 2.0.2
:class:`decimal.Decimal` is supported by converting to a string.
.. versionchanged:: 2.0
``encoding`` will be removed in Flask 2.1.
.. versionchanged:: 1.0.3
``app`` can be passed directly, rather than requiring an app
context for configuration.
"""
if current_app:
return current_app.json.dumps(obj, **kwargs)
kwargs.setdefault("default", _default)
return _json.dumps(obj, **kwargs)
def dump(obj: t.Any, fp: t.IO[str], **kwargs: t.Any) -> None:
"""Serialize data as JSON and write to a file.
If :data:`~flask.current_app` is available, it will use its
:meth:`app.json.dump() <flask.json.provider.JSONProvider.dump>`
method, otherwise it will use :func:`json.dump`.
:param obj: The data to serialize.
:param fp: A file opened for writing text. Should use the UTF-8
encoding to be valid JSON.
:param kwargs: Arguments passed to the ``dump`` implementation.
.. versionchanged:: 2.3
The ``app`` parameter was removed.
// ... (111 more lines)
Domain
Subdomains
Dependencies
- _default
- globals
- json
- provider.py
- typing
- wrappers
Imported By
Source
Frequently Asked Questions
What does __init__.py do?
__init__.py is a source file in the flask codebase, written in python. It belongs to the DataHandling domain, JsonProvider subdomain.
What functions are defined in __init__.py?
__init__.py defines 6 function(s): dump, dumps, jsonify, load, loads, wrappers.
What does __init__.py depend on?
__init__.py imports 6 module(s): _default, globals, json, provider.py, typing, wrappers.
What files import __init__.py?
__init__.py is imported by 2 file(s): __init__.py, config.py.
Where is __init__.py in the architecture?
__init__.py is located at src/flask/json/__init__.py (domain: DataHandling, subdomain: JsonProvider, directory: src/flask/json).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free