MCPcopy
hub / github.com/fastapi/fastapi / serialize_json

Method serialize_json

fastapi/_compat/v2.py:215–239  ·  view source on GitHub ↗
(
        self,
        value: Any,
        *,
        include: IncEx | None = None,
        exclude: IncEx | None = None,
        by_alias: bool = True,
        exclude_unset: bool = False,
        exclude_defaults: bool = False,
        exclude_none: bool = False,
    )

Source from the content-addressed store, hash-verified

213 )
214
215 def serialize_json(
216 self,
217 value: Any,
218 *,
219 include: IncEx | None = None,
220 exclude: IncEx | None = None,
221 by_alias: bool = True,
222 exclude_unset: bool = False,
223 exclude_defaults: bool = False,
224 exclude_none: bool = False,
225 ) -> bytes:
226 # What calls this code passes a value that already called
227 # self._type_adapter.validate_python(value)
228 # This uses Pydantic's dump_json() which serializes directly to JSON
229 # bytes in one pass (via Rust), avoiding the intermediate Python dict
230 # step of dump_python(mode="json") + json.dumps().
231 return self._type_adapter.dump_json(
232 value,
233 include=include,
234 exclude=exclude,
235 by_alias=by_alias,
236 exclude_unset=exclude_unset,
237 exclude_defaults=exclude_defaults,
238 exclude_none=exclude_none,
239 )
240
241 def __hash__(self) -> int:
242 # Each ModelField is unique for our purposes, to allow making a dict from

Callers 1

_serialize_dataFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected