Closed Bug 509339 Opened 15 years ago Closed 15 years ago

JSON.stringify does not serialise function objects

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: oliver, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6; en-us) AppleWebKit/531.5 (KHTML, like Gecko) Version/4.0.3 Safari/531.7
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2

When serialising an object using JSON.stringify function objects are incorrectly serialised to undefined instead of being treated as a stnadard object.  This is covered by section 15.12.3, where any non-array object is serialised with the algorithm JO.

Reproducible: Always

Steps to Reproduce:
1.  javascript:alert(JSON.serialise(function(){}))
Actual Results:  
alerts undefined

Expected Results:  
It should alert the string '{}'
For reference this incorrect implementation is already causing bugs to be filed on webkit, it would be great if it could be fixed soon.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
Sigh, missed IsCallable -- was looking for "function" :-/
You need to log in before you can comment on or make changes to this bug.