pub fn redefine_static_methods(ctx: &Ctx<'_>) -> Result<()>Expand description
Replace JSON.parse / JSON.stringify with this module’s.
NOT called by crate::init, and not ready to be. It is about a
third faster than the engine’s both ways, but measured against Node
it still differs in ways that matter:
parseassigns keys through[[Set]], so{"__proto__": {...}}retargets the result’s prototype rather than becoming an own property. For a runtime that parses untrusted JSON that is a prototype-pollution primitive, and it is the reason this is off.parseignores itsreviverargument entirely.stringifywrites a hole or anundefinedarray element as nothing rather thannull, which emits invalid JSON ([1,,2]).stringifydoes not unwrap boxed primitives:new Number(5)serialises as{}where the spec says5.stringifywrites-0for negative zero (spec:0) and1e21where the spec’s ToString gives1e+21.
crates/ferrijs/tests/json_conformance.rs is the set these came
from; make it pass before turning this on.