« Bugzilla Issues Index
#171 — should review primitive value conversion in JSON.stringify
- bug_id:
171
- creation_ts:
2011-07-25 16:51:00 -0700
- short_desc:
should review primitive value conversion in JSON.stringify
- delta_ts:
2015-02-16 12:57:47 -0800
- product:
Draft for 6th Edition
- component:
technical issue
- version:
Initial draft July 12, 2011
- rep_platform:
All
- op_sys:
All
- bug_status:
RESOLVED
- resolution:
WONTFIX
- priority:
Normal
- bug_severity:
minor
- everconfirmed:
true
- reporter:
Allen Wirfs-Brock
- assigned_to:
Allen Wirfs-Brock
- commentid:
384
- comment_count:
0
- who:
Allen Wirfs-Brock
- bug_when:
2011-07-25 16:51:39 -0700
see https://mail.mozilla.org/pipermail/es5-discuss/2011-March/003945.html
- commentid:
12779
- comment_count:
1
- who:
Allen Wirfs-Brock
- bug_when:
2015-02-16 12:57:47 -0800
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.