diff --git a/src/openseadragon.js b/src/openseadragon.js index 64349972..18de8f4f 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -2176,6 +2176,24 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ return $.parseXml( string ); }, + /** + * Parses a JSON string into a Javascript object. + * @function + * @param {String} string + * @returns {Object} + */ + parseJSON: function(string) { + if (window.JSON && window.JSON.parse) { + $.parseJSON = window.JSON.parse; + } else { + // Should only be used by IE8 in non standards mode + $.parseJSON = function(string) { + /*jshint evil:true*/ + return eval('(' + string + ')'); + }; + } + return $.parseJSON(string); + }, /** * Reports whether the image format is supported for tiling in this diff --git a/src/tilesource.js b/src/tilesource.js index 48d5bf10..65841d25 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -613,8 +613,7 @@ function processResponse( xhr ){ data = xhr.responseText; } }else if( responseText.match(/\s*[\{\[].*/) ){ - /*jshint evil:true*/ - data = eval( '('+responseText+')' ); + data = $.parseJSON(responseText); }else{ data = responseText; }