Reviewers: Vyacheslav Egorov, Description: Fix JSON.parse typo which causes the input not to be string converted.
Please review this at http://codereview.chromium.org/2981004/show SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/json.js M test/mjsunit/json.js Index: src/json.js =================================================================== --- src/json.js (revision 5045) +++ src/json.js (working copy) @@ -29,7 +29,7 @@ function ParseJSONUnfiltered(text) { var s = $String(text); - var f = %CompileString(text, true); + var f = %CompileString(s, true); return f(); } Index: test/mjsunit/json.js =================================================================== --- test/mjsunit/json.js (revision 5045) +++ test/mjsunit/json.js (working copy) @@ -85,7 +85,7 @@ }; assertEquals(null, n4.toJSON()); -assertEquals(Object.prototype, JSON.__proto__); +assertTrue(Object.prototype === JSON.__proto__); assertEquals("[object JSON]", Object.prototype.toString.call(JSON)); // DontEnum @@ -313,3 +313,7 @@ var x = 0; eval("(1); x++; (1)"); TestInvalid('1); x++; (1'); + +// Test string conversion of argument. +var o = { toString: function() { return "42"; } }; +assertEquals(42, JSON.parse(o)); -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
