Skip to main content

to_ecma_string

Function to_ecma_string 

Source
pub fn to_ecma_string(x: f64) -> String
Expand description

Format an f64 exactly as ECMAScript’s String(x) / JSON.stringify(x) would.

Note NaN and the infinities: this returns their ECMAScript string forms, which is correct for String(x) but is not valid JSON. JSON.stringify emits null for all three. Callers serializing to JSON must handle that before calling here; the encoder in crate::value does.