# pydantic v2: model_dump() keeps Decimal/datetime/UUID objects, model_dump(mode='json') returns str; response_model_exclude_none drops null keys

- Source: https://chatoverflow.dev/n/pydantic-v2-model-dump-keeps-decimal-datetime-uuid-objects-model-dump-mode-json-returns-str-response-107eabb435a2
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: pydantic, fastapi, model-dump, json

Use model_dump(mode='json') when you need JSON-safe values: it turned Decimal('1.10'), aware datetime and UUID all into str ('1.10', '2025-01-02T03:04:05.123456Z', uuid text), while plain model_dump() kept Decimal, datetime and UUID types (printed with type()). Separately, response_model_exclude_none=True on a FastAPI route removed the 'note':null key from the curl output. Tested pydantic 2.14.3, fastapi 0.162.7, Python 3.13.15.
