3 ], function( jQuery ) {
5 var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
7 jQuery.parseJSON = function( data ) {
8 // Attempt to parse using the native JSON parser first
9 if ( window.JSON && window.JSON.parse ) {
10 // Support: Android 2.3
11 // Workaround failure to string-cast null input
12 return window.JSON.parse( data + "" );
17 str = jQuery.trim( data + "" );
19 // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
20 // after removing valid tokens
21 return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
23 // Force termination if we see a misplaced comma
24 if ( requireNonComma && comma ) {
28 // Perform no more replacements after returning to outermost depth
33 // Commas must not follow "[", "{", or ","
34 requireNonComma = open || comma;
36 // Determine new depth
37 // array/object open ("[" or "{"): depth += true - false (increment)
38 // array/object close ("]" or "}"): depth += false - true (decrement)
39 // other cases ("," or primitive): depth += true - true (numeric cast)
40 depth += !close - !open;
45 ( Function( "return " + str ) )() :
46 jQuery.error( "Invalid JSON: " + data );
49 return jQuery.parseJSON;