pub fn expect_number_as_string_or_null<'a>(
token: Option<Result<Token<'a>, DeserializeError>>,
input: &'a [u8],
) -> Result<Option<&'a str>, DeserializeError>Expand description
Expects a Token::ValueNumber or Token::ValueNull, and returns the number as a string to preserve arbitrary precision.
This function extracts the raw JSON number string without converting it to u64/i64/f64, which would cause precision loss for numbers larger than those types can represent. This is essential for BigInteger and BigDecimal support.
§Arguments
token- The token to extract the number frominput- The original JSON input bytes (needed to extract the raw number string)
§Returns
Ok(Some(string))- The number as a string sliceOk(None)- If the token is nullErr- If the token is not a number or null