WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
28118
JSON.stringify replacer returning undefined does not omit object properties
https://bugs.webkit.org/show_bug.cgi?id=28118
Summary
JSON.stringify replacer returning undefined does not omit object properties
Luke Smith
Reported
2009-08-08 21:17:29 PDT
JSON.stringify({remove:"me"}, function (k,v) { return k === 'remove' ? undefined : v; }) should return '{}', but returns '{"remove":null}' Per the ECMA5 spec, undefined returned from a replacer should result in omission from the resulting JSON string in the case of object properties, and null in the case of array items. Currently, null is used for both cases.
r46919
Attachments
Patch v1
(9.62 KB, patch)
2009-08-09 16:15 PDT
,
Oliver Hunt
staikos
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Mark Rowe (bdash)
Comment 1
2009-08-09 13:36:59 PDT
<
rdar://problem/7129376
>
Oliver Hunt
Comment 2
2009-08-09 14:53:52 PDT
Goddammit -- fixed locally. Stupid mistake, and i was sure this worked at one point. It must have got broken when darin made this code iterative. Apparently replacer functions aren't being tested as thoroughly as might be hoped. Anyhoo, fixed locally just need to turn a build to verify that all is well, and add tests
Oliver Hunt
Comment 3
2009-08-09 16:15:46 PDT
Created
attachment 34435
[details]
Patch v1
George Staikos
Comment 4
2009-08-09 16:33:57 PDT
Comment on
attachment 34435
[details]
Patch v1
> // Handle cycle detection, and put the holder on the stack. > if (!m_holderCycleDetector.add(object).second) { > - throwError(m_exec, TypeError); > + throwError(m_exec, TypeError, "JSON.stringify cannot serialise cyclic structures."); > return StringifyFailed;
Should we not prefer US English?
George Staikos
Comment 5
2009-08-09 16:52:22 PDT
Comment on
attachment 34435
[details]
Patch v1 r=me with the spelling fixed.
Oliver Hunt
Comment 6
2009-08-09 16:56:07 PDT
Committed
r46967
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug