Created
April 29, 2009 18:19
-
-
Save lsmith/103949 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add('json-trusted', function (Y) { | |
function evalWrapper(str) { return eval('('+str+')'); } | |
Y.namespace('TrustedJSON').parse = | |
(Object.prototype.toString.call(window.JSON) === '[object JSON]') ? | |
function (str) { | |
return /^\s*(?:"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)\s*$/.test(str) ? | |
evalWrapper(str) : // FF3.5 Native does not support non-object/array input | |
JSON.parse(str); | |
} : | |
evalWrapper; | |
}, '@VERSION@'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment