jsonable_encoder() — fastapi Function Reference
Architecture documentation for the jsonable_encoder() function in encoders.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 1ac1bc37_1a47_e7e2_9156_ab0473094700["jsonable_encoder()"] ea747667_035c_8539_a8f7_f347fb7e7c39["encoders.py"] 1ac1bc37_1a47_e7e2_9156_ab0473094700 -->|defined in| ea747667_035c_8539_a8f7_f347fb7e7c39 50aacdd6_70bd_b68e_a29f_c05fd21e0448["update_item()"] 50aacdd6_70bd_b68e_a29f_c05fd21e0448 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 b56e0976_378d_856a_cb7b_b97f3ec73e10["update_item()"] b56e0976_378d_856a_cb7b_b97f3ec73e10 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 00d20852_5b0e_b44c_03b2_48d140770a6f["update_item()"] 00d20852_5b0e_b44c_03b2_48d140770a6f -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 70e0a458_870a_db8c_5e2f_2c4468a63021["update_item()"] 70e0a458_870a_db8c_5e2f_2c4468a63021 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 880ca742_c2b1_ae7e_6682_49b5c36a5251["update_item()"] 880ca742_c2b1_ae7e_6682_49b5c36a5251 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 aceb3648_b2d6_da30_1212_ff6d29ee30f9["update_item()"] aceb3648_b2d6_da30_1212_ff6d29ee30f9 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 b0932b49_ef9e_cadd_e3e1_0c5b962e9b6b["validation_exception_handler()"] b0932b49_ef9e_cadd_e3e1_0c5b962e9b6b -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 63329d88_dc14_f0ca_0259_a76cffe8fe3f["update_item()"] 63329d88_dc14_f0ca_0259_a76cffe8fe3f -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 b512380e_fc59_507d_df51_08fb49181af1["update_item()"] b512380e_fc59_507d_df51_08fb49181af1 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 2d028bc8_34b4_6303_1406_f7c12b4394e6["request_validation_exception_handler()"] 2d028bc8_34b4_6303_1406_f7c12b4394e6 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 1d7ecc02_0319_a836_bffe_6f17ba1fc0ac["websocket_request_validation_exception_handler()"] 1d7ecc02_0319_a836_bffe_6f17ba1fc0ac -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 3705e434_dfc7_b070_aae6_93314a9b9976["get_swagger_ui_html()"] 3705e434_dfc7_b070_aae6_93314a9b9976 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 6c126127_cb4d_c433_3a3a_b84c50ec62e9["get_openapi_security_definitions()"] 6c126127_cb4d_c433_3a3a_b84c50ec62e9 -->|calls| 1ac1bc37_1a47_e7e2_9156_ab0473094700 style 1ac1bc37_1a47_e7e2_9156_ab0473094700 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/encoders.py lines 111–346
def jsonable_encoder(
obj: Annotated[
Any,
Doc(
"""
The input object to convert to JSON.
"""
),
],
include: Annotated[
Optional[IncEx],
Doc(
"""
Pydantic's `include` parameter, passed to Pydantic models to set the
fields to include.
"""
),
] = None,
exclude: Annotated[
Optional[IncEx],
Doc(
"""
Pydantic's `exclude` parameter, passed to Pydantic models to set the
fields to exclude.
"""
),
] = None,
by_alias: Annotated[
bool,
Doc(
"""
Pydantic's `by_alias` parameter, passed to Pydantic models to define if
the output should use the alias names (when provided) or the Python
attribute names. In an API, if you set an alias, it's probably because you
want to use it in the result, so you probably want to leave this set to
`True`.
"""
),
] = True,
exclude_unset: Annotated[
bool,
Doc(
"""
Pydantic's `exclude_unset` parameter, passed to Pydantic models to define
if it should exclude from the output the fields that were not explicitly
set (and that only had their default values).
"""
),
] = False,
exclude_defaults: Annotated[
bool,
Doc(
"""
Pydantic's `exclude_defaults` parameter, passed to Pydantic models to define
if it should exclude from the output the fields that had the same default
value, even when they were explicitly set.
"""
),
] = False,
exclude_none: Annotated[
bool,
Doc(
"""
Pydantic's `exclude_none` parameter, passed to Pydantic models to define
if it should exclude from the output any fields that have a `None` value.
"""
),
] = False,
custom_encoder: Annotated[
Optional[dict[Any, Callable[[Any], Any]]],
Doc(
"""
Pydantic's `custom_encoder` parameter, passed to Pydantic models to define
a custom encoder.
"""
),
] = None,
sqlalchemy_safe: Annotated[
bool,
Doc(
"""
Domain
Subdomains
Defined In
Called By
- _get_openapi_operation_parameters()
- get_openapi()
- get_openapi_operation_request_body()
- get_openapi_security_definitions()
- get_swagger_ui_html()
- request_validation_exception_handler()
- serialize_response()
- test_custom_encoders()
- test_custom_enum_encoders()
- test_decimal_encoder_float()
- test_decimal_encoder_infinity()
- test_decimal_encoder_int()
- test_decimal_encoder_nan()
- test_encode_class()
- test_encode_custom_json_encoders_model_pydanticv2()
- test_encode_dataclass()
- test_encode_deque_encodes_child_models()
- test_encode_dict()
- test_encode_dict_include_exclude_list()
- test_encode_dictable()
- test_encode_model_with_alias()
- test_encode_model_with_config()
- test_encode_model_with_default()
- test_encode_model_with_pure_path()
- test_encode_model_with_pure_posix_path()
- test_encode_model_with_pure_windows_path()
- test_encode_pure_path()
- test_encode_pydantic_undefined()
- test_encode_unsupported()
- test_json_encoder_error_with_pydanticv1()
- update_item()
- update_item()
- update_item()
- update_item()
- update_item()
- update_item()
- update_item()
- update_item()
- validation_exception_handler()
- websocket_request_validation_exception_handler()
Source
Frequently Asked Questions
What does jsonable_encoder() do?
jsonable_encoder() is a function in the fastapi codebase, defined in fastapi/encoders.py.
Where is jsonable_encoder() defined?
jsonable_encoder() is defined in fastapi/encoders.py at line 111.
What calls jsonable_encoder()?
jsonable_encoder() is called by 40 function(s): _get_openapi_operation_parameters, get_openapi, get_openapi_operation_request_body, get_openapi_security_definitions, get_swagger_ui_html, request_validation_exception_handler, serialize_response, test_custom_encoders, and 32 more.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free