]> source.dussan.org Git - jquery.git/commitdiff
2.0: Remove JSON.parse shim
authorRick Waldron <waldron.rick@gmail.com>
Mon, 17 Dec 2012 22:02:23 +0000 (17:02 -0500)
committerRick Waldron <waldron.rick@gmail.com>
Wed, 26 Dec 2012 18:34:36 +0000 (13:34 -0500)
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
src/core.js

index 44ad7fe672f50d8115d994f74e36881d9c821946..d4166ce198c0083843bafcae51dd3e55effc3fd2 100644 (file)
@@ -52,12 +52,6 @@ var
        // Match a standalone tag
        rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
 
-       // JSON RegExp
-       rvalidchars = /^[\],:{}\s]*$/,
-       rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
-       rvalidescape = /\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,
-       rvalidtokens = /"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,
-
        // Matches dashed string for camelizing
        rmsPrefix = /^-ms-/,
        rdashAlpha = /-([\da-z])/gi,
@@ -495,33 +489,7 @@ jQuery.extend({
        },
 
        parseJSON: function( data ) {
-               // Attempt to parse using the native JSON parser first
-               if ( window.JSON && window.JSON.parse ) {
-                       return window.JSON.parse( data );
-               }
-
-               if ( data === null ) {
-                       return data;
-               }
-
-               if ( typeof data === "string" ) {
-
-                       // Make sure leading/trailing whitespace is removed (IE can't handle it)
-                       data = jQuery.trim( data );
-
-                       if ( data ) {
-                               // Make sure the incoming data is actual JSON
-                               // Logic borrowed from http://json.org/json2.js
-                               if ( rvalidchars.test( data.replace( rvalidescape, "@" )
-                                       .replace( rvalidtokens, "]" )
-                                       .replace( rvalidbraces, "")) ) {
-
-                                       return ( new Function( "return " + data ) )();
-                               }
-                       }
-               }
-
-               jQuery.error( "Invalid JSON: " + data );
+               return window.JSON.parse( data );
        },
 
        // Cross-browser xml parsing