Closed Bug 505228 Opened 15 years ago Closed 15 years ago

JSON.stringify generates non standard output if "space" is defined

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: fabian.jakobs, Assigned: wesongathedeveloper)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(2 files, 2 obsolete files)

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 "]".
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.3a1pre) Gecko/20090823 Minefield/3.7a1pre Confirmed.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
OS: Mac OS X → All
Attached patch Patch v1 (obsolete) — Splinter Review
Assignee: general → wesongathedeveloper
Status: NEW → ASSIGNED
Attachment #398972 - Flags: review?(sayrer)
good patch. it needs a test, though.
Attached patch Patch (obsolete) — Splinter Review
Attachment #398972 - Attachment is obsolete: true
Attachment #405205 - Flags: review?(sayrer)
Attachment #398972 - Flags: review?(sayrer)
Attachment #405205 - Flags: review?(sayrer) → review+
Attached patch PatchSplinter Review
Applies cleanly.
Attachment #405205 - Attachment is obsolete: true
Keywords: checkin-needed
Flags: in-testsuite+
Whiteboard: fixed-in-tracemonkey
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.

Attachment

General

Creator:
Created:
Updated:
Size: