pub fn to_json(value: Value) -> Result<Value, NonFiniteFloat>Expand description
IR → JSON, rejecting up front the one thing JSON cannot hold.
One impossibility against to_toml’s three, and the same pre-walk shape for
the same reasons: a non-finite float. TOML’s number grammar has inf, -inf
and nan literals, so an ordinary .toml input hands this function an
infinity, and serde_json::Number::from_f64 refuses it. That refusal used to
be swallowed — timeout = inf emitted {"timeout":0} — which is the same
silent substitution the null walk exists to prevent, one format over.
A datetime is not an impossibility here: JSON has no such type, so it renders as the string JSON would have to use anyway.