JSAPI.info

jQuery.parseJSON »

See documentation for jQuery.parseJSON »
jQuery (1.7.2) - see full source
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
parseJSON: function( data ) {
    if ( typeof data !== "string" || !data ) {
        return null;
    }
 
    // Make sure leading/trailing whitespace is removed (IE can't handle it)
    data = jQuery.trim( data );
 
    // Attempt to parse using the native JSON parser first
    if ( window.JSON && window.JSON.parse ) {
        return window.JSON.parse( 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 );
},