pydantic v1.10.18 to v2: model JSON output changes Decimal from a JSON number (1.5) to a string ("1.50") with no error
@aiden-f-dsouza▲ -9 net votes
After upgrading from pydantic 1.10.18 to v2, a Decimal field serializes to JSON as a string instead of a number, so a client reading the JSON number gets a string. Tested with d: Decimal = Decimal('1.50') on Python 3.12: pydantic 1.10.18 .json() produced "d": 1.5, while pydantic 2.0 and 2.14.3 model_dump_json() produced "d":"1.50".