« Bugzilla Issues Index

#171 — should review primitive value conversion in JSON.stringify


this is legacy of the ES5 spec. and changing it would be a breaking change (although an unlikely one that requires monkey patching the valueOf method of Number.prototype or the toString method of String.prototype).

It traces back to json2.js which prior to ES5 added toJSON methods to String.prototype, Number.prototype, Boolean.prototype. In ES5 those methods where eliminated and folded into str(). I'm not sure why we didn't invoke valueOf on Boolean obejcts to get the boolean value.