I have some JS code that reads a JSON file in and stores the object:
var queryString = (function () {
var queryString = null;
$.ajax({
'async': false,
'global': false,
'url': 'scripts/largeJson.json',
'dataType': "json",
'success': function (data) {
queryString = data;
}
});
return queryString;
})();
console.log("LargeJson:" + JSON.stringify(queryString));
This works in general, with a small JSON file, I have no problems, and the JSON object is correctly stored in the queryString variable and correctly printed at the last line.
However, when I am using a larger json file (~700 lines), the queryString variable will be null at the last line of this snippet. I should be running this code synchronously due to the async
param. What could be going on here? Does this indicate that my larger file is in some way corrupt? I have run it through a few validators with no problems.