archives

« Bugzilla Issues Index

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


see https://mail.mozilla.org/pipermail/es5-discuss/2011-March/003945.html


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.