Closed Bug 501156 Opened 15 years ago Closed 15 years ago

JSON.parse fails to parse an escaped string with a double backslash

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

VERIFIED INVALID

People

(Reporter: robert, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009052808 Gentoo Firefox/3.0.10
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)

Code: JSON.parse("\"T\\wo\"");

Results in a parse exception SyntaxError.

This works perfectly fine in:
* window.eval
* GWT 1.6's JSON parsing
* json.org's json2.js from date 1-17-2008

Fails in:
* FF 3.5
* json.org's latest json2.js


Is this as designed or a bug?
If works as designed, does this mean GWT's JSON parsing and the older json.org json2.js is/was bugged?

Reproducible: Always

Steps to Reproduce:
1. JSON.parse("\"T\\wo\"");
Actual Results:  
SyntaxError: JSON.parse

Expected Results:  
Two
I updated the test page with the eval snippet from the RFC
http://www.ietf.org/rfc/rfc4627.txt?number=4627

It also works correctly. Giving the output of: Two
This is by design according to Douglas Crockford here: http://tech.groups.yahoo.com/group/json/message/1286

Marking this bug as INVALID.
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.