Closed Bug 537483 Opened 15 years ago Closed 15 years ago

JSON.parse doesn't correctly add properties with numeric identifiers

Categories

(Rhino Graveyard :: Core, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: rspeyer, Unassigned)

References

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.4) Gecko/20091006 Firefox/3.5.4 Build Identifier: Rhino 1.7 release 3 PRERELEASE JSON.parse simply treats all property identifiers as strings, whereas retrieval of properties from objects assumes that if a property identifier can be parsed as an int, it will have been added as an int (index property). Reproducible: Always Steps to Reproduce: JSON.parse("{\"1\": true}")["1"] Actual Results: undefined Expected Results: true
Blocks: 505211
Committed patch, thanks! Checking in src/org/mozilla/javascript/json/JsonParser.java; /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/json/JsonParser.java,v <-- JsonParser.java new revision: 1.7; previous revision: 1.6 done RCS file: /cvsroot/mozilla/js/rhino/testsrc/doctests/json.doctest,v done Checking in testsrc/doctests/json.doctest; /cvsroot/mozilla/js/rhino/testsrc/doctests/json.doctest,v <-- json.doctest initial revision: 1.1 done
Status: UNCONFIRMED → 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: