JSON.stringify(_1, _2, numberGreaterThanOne) implemented by imbeciles

RESOLVED FIXED

Status

()

RESOLVED FIXED
8 years ago
8 years ago

People

(Reporter: Waldo, Assigned: Waldo)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(2 attachments)

(Assignee)

Description

8 years ago
Like, dude:

[jwalden@find-waldo-now src]$ dbg/js -j
js> var obj = {a1: {b1: [1, 2, 3, 4], b2: {c1: 1, c2: 2}}, a2: "a2"};
js> print(JSON.stringify(obj, null, 5))
     {"a1":{"b1":[1,2,3,4],"b2":{"c1":1,"c2":2}},"a2":"a2"}
js> print(JSON.stringify(obj, null, "     "))
{
     "a1":{
          "b1":[
               1,
               2,
               3,
               4
          ],
          "b2":{
               "c1":1,
               "c2":2
          }
     },
     "a2":"a2"
}

For comparison v8's result (whose differences from our behavior do appear to be to-spec):

{
     "a1": {
          "b1": [
               1,
               2,
               3,
               4
          ],
          "b2": {
               "c1": 1,
               "c2": 2
          }
     },
     "a2": "a2"
}

The missing space between ':' and property value goes back far enough in hg history that it, in contrast to the space-as-number handling, may precede ES5 specification of behavior, so I will partially excuse its incorrectness as I fix it in passing.

Patch shortly, after it passes tests (and after I write some).
(Assignee)

Comment 1

8 years ago
Created attachment 463358 [details] [diff] [review]
1: s/AutoIdArray/AutoIdVector/

This isn't necessary to this bug, but I noted it in passing and it seemed easy to fix now.
Attachment #463358 - Flags: review?(sayrer)
(Assignee)

Comment 2

8 years ago
Created attachment 463359 [details] [diff] [review]
2: Fix gap handling

This actually fixes stuff, and it adds a test for correctness.
Attachment #463359 - Flags: review?(sayrer)

Updated

8 years ago
Attachment #463358 - Flags: review?(sayrer) → review+

Updated

8 years ago
Attachment #463359 - Flags: review?(sayrer) → review+
(Assignee)

Comment 4

8 years ago
...and this to fix one other test missed in previous fixing:

http://hg.mozilla.org/tracemonkey/rev/e6bc387f60da

Comment 5

8 years ago
http://hg.mozilla.org/mozilla-central/rev/aae5edb1edc6
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.