-
-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
When using JsonValue::parse_with_config, fractional JSON numbers are parsed into Float(f64), so the original literal is lost. Downstream (e.g., pydantic-core’s JsonValidator path) cannot build a Decimal from the original text and only sees f64.to_string(), causing precision loss.
Ask: add an opt‑in mode on the JsonValue parsing path that preserves the raw numeric token (e.g., a lossless number variant or raw text) so consumers can construct Decimal without going through f64.
References:
crates/jiter/src/value.rs:JsonValueenum currently usesFloat(f64)for fractional numbers.- pydantic-core invokes
JsonValue::parse_with_configinpydantic-core/src/validators/json.rs::JsonValidator. - Related pydantic issue: Decoding Decimal from JSON number is lossy pydantic#9180 (Decimal precision loss when parsing JSON numbers via JsonValue).
Context: Workarounds are parsing via PythonParse with FloatMode::Decimal or passing numbers as strings. An opt‑in lossless JsonValue mode would let pydantic-core keep its existing pipeline while preserving precision.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels