diff --git a/src/json.js b/src/json.js index cdb10be1aa..e7ec6100e5 100644 --- a/src/json.js +++ b/src/json.js @@ -29,7 +29,7 @@ var $JSON = global.JSON; function ParseJSONUnfiltered(text) { var s = $String(text); - var f = %CompileString(text, true); + var f = %CompileString(s, true); return f(); } diff --git a/test/mjsunit/json.js b/test/mjsunit/json.js index 85457cd6e1..945b66249b 100644 --- a/test/mjsunit/json.js +++ b/test/mjsunit/json.js @@ -85,7 +85,7 @@ n4.toISOString = function () { }; 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 @@ TestInvalid('1); throw "foo"; (1'); 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));