Sha256: 0ca9fcbf0091bd09310e8a3daaf8b036c297eb5ed1b08af6578707e56dd95c08

Contents?: true

Size: 1.45 KB

Versions: 401

Compression:

Stored size: 1.45 KB

Contents

define( [
	"../core"
], function( jQuery ) {

var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;

jQuery.parseJSON = function( data ) {

	// Attempt to parse using the native JSON parser first
	if ( window.JSON && window.JSON.parse ) {

		// Support: Android 2.3
		// Workaround failure to string-cast null input
		return window.JSON.parse( data + "" );
	}

	var requireNonComma,
		depth = null,
		str = jQuery.trim( data + "" );

	// Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
	// after removing valid tokens
	return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {

		// Force termination if we see a misplaced comma
		if ( requireNonComma && comma ) {
			depth = 0;
		}

		// Perform no more replacements after returning to outermost depth
		if ( depth === 0 ) {
			return token;
		}

		// Commas must not follow "[", "{", or ","
		requireNonComma = open || comma;

		// Determine new depth
		// array/object open ("[" or "{"): depth += true - false (increment)
		// array/object close ("]" or "}"): depth += false - true (decrement)
		// other cases ("," or primitive): depth += true - true (numeric cast)
		depth += !close - !open;

		// Remove this token
		return "";
	} ) ) ?
		( Function( "return " + str ) )() :
		jQuery.error( "Invalid JSON: " + data );
};

return jQuery.parseJSON;

} );

Version data entries

401 entries across 401 versions & 2 rubygems

Version Path
govuk_publishing_components-28.9.2 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.9.1 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.9.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.8.1 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.8.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.7.1 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.6.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.5.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.4.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.3.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.2.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.1.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-28.0.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-27.20.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-27.19.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-27.18.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-27.17.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-27.16.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-27.15.0 node_modules/jquery/src/ajax/parseJSON.js
govuk_publishing_components-27.14.2 node_modules/jquery/src/ajax/parseJSON.js