Closed
Bug 505228
Opened 16 years ago
Closed 15 years ago
JSON.stringify generates non standard output if "space" is defined
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: fabian.jakobs, Assigned: wesongathedeveloper)
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(2 files, 2 obsolete files)
208 bytes,
text/html
|
Details | |
1.25 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; de; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1
If the "space" argument of the JSON.stringify method is given, arrays are not correctly
stringified as expected by the EcmaScript 3.1 specification. Firefox does not insert
a new line character after the opening bracket:
Current behavior:
alert(JSON.stringify(['e'], null, '\t'))
["e"
]
expected:
[
"e"
]
Quote from the spec:
9. If partial is empty ,then
a. Let final be "[]".
10. Else
a. If gap is the empty string
i. Let properties be a string formed by concatenating all the element strings of partial
with each adjacent pair of strings separated with the comma character. A comma is
not inserted either before the first string or after the last string.
ii. Let final be the result of concatenating "[", properties, and "]".
b. Else
i. Let separator be the result of concatenating the comma character, the line feed
character, and indent.
ii. Let properties be a string formed by concatenating all the element strings of partial
with each adjacent pair of strings separated with separator. The separator string is
not inserted either before the first string or after the last string.
iii. Let final be the result of concatenating "[", the line feed character, indent,
properties, the line feed character, stepback, and "]".
Comment 1•15 years ago
|
||
Comment 2•15 years ago
|
||
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20090823 Minefield/3.7a1pre
Confirmed.
Assignee | ||
Comment 3•15 years ago
|
||
Assignee: general → wesongathedeveloper
Status: NEW → ASSIGNED
Attachment #398972 -
Flags: review?(sayrer)
Comment 4•15 years ago
|
||
good patch. it needs a test, though.
Assignee | ||
Comment 5•15 years ago
|
||
Attachment #398972 -
Attachment is obsolete: true
Attachment #405205 -
Flags: review?(sayrer)
Attachment #398972 -
Flags: review?(sayrer)
Updated•15 years ago
|
Attachment #405205 -
Flags: review?(sayrer) → review+
Assignee | ||
Comment 6•15 years ago
|
||
Applies cleanly.
Attachment #405205 -
Attachment is obsolete: true
Assignee | ||
Updated•15 years ago
|
Keywords: checkin-needed
Comment 7•15 years ago
|
||
Comment 8•15 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•