[Webkit-unassigned] [Bug 28117] Native JSON.stringify does not omit functions

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Aug 9 20:31:51 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=28117


Luke Smith <lsmith at lucassmith.name> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |




--- Comment #4 from Luke Smith <lsmith at lucassmith.name>  2009-08-09 20:31:50 PDT ---
Per the final draft of the ECMA 5 spec located at
http://www.ecma-international.org/publications/files/drafts/tc39-2009-025.pdf

Section 15.12.3 states in the definition of the Str abstract function
4. If value is null then return "null". 
5. If value is true then return "true". 
6. If value is false then return "false". 
7. If Type(value) is object then, 
a. If the [[Class]] internal property of value is "Number" then, 
i. Let value be ToNumber(value). 
b. Else if the [[Class]] internal property of value is "String" then, 
i. Let value be ToString(value). 
8. If Type(value) is string, then return the result of calling the abstract
operation Quote with argument 
value. 
9. If Type(value) is number 
a. If value is finite then return ToString(value). 
b. else, return "null". 
10. If Type(value) is object, and IsCallable(value) is false 
a. If the [[Class]] internal property of value is "Array" then 
i. Return the result of calling the abstract operation JA with argument value. 
b. Return the result of calling the abstract operation JO with argument value. 
11. Return undefined.


Note 10. and IsCallable(value) is false

Also, every implementation of JSON including the reference implementation by
Douglas Crockford treats functions as it would undefined.

>From Crockford's http://json.org/json2.js
"Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined."

>From http://json.org/js.html
"Values that do not have a representation in JSON (such as functions and
undefined) are excluded."

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list