I am facing an issue with a substantial JSON file that my JavaScript code is unable to pull in entirely. When I check the Network tab in Firefox developer tools, it shows that the data stops at around line 57,301 out of 528,342 lines in the JSON file.
Initially, I attempted to fetch the data directly but encountered errors related to the necessity of using 'await' alongside asynchronous functions, which I am not well-versed in. For my xmlhttp request, I had set the async flag to false as it was the only way I could make it work with my current code.
The JSON objects I am trying to retrieve contain latitude, longitude, and altitude information, structured as follows:
{"points":[
{"lat": 0, "lon": 0},
.
.
.
{"lat": 0, "lon": 0}]}
Here's how my request is currently coded:
function get_json_data(){
var data = [];
var response = new XMLHttpRequest();
response.onreadystatechange = function(){
data_points = JSON.parse(this.responseText);
*** CONVERTING LAT/LON TO ARRAY AND PUTTING INTO DATA ***
});
response.open("GET", "http://url/path/to/json", false);
response.send();
return data;
}
While this approach works smoothly for smaller JSON files, say around 10,000 lines, I'm struggling to handle much larger files containing over 500,000 lines. Any suggestions on how I can successfully process such massive JSON files?