Loading large JSON file

Asked

Viewed 271 times

1

Staff I have equipment here that provides a log on JSON which is inserts the data each 2 seconds,It provides this log for reading, the problem is that this file has log 30 days, I am using ajax to grab the data but it takes a lot (~ around 3.6 minutes) to read the entire file, Is there any way to do this faster, because I just want to get the last value being inserted in the log. I’m having it like this:

function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      console.log(this);
      document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "http://10.0.0.1/log.json", true);
  xhttp.send();
  }

  • You should separate that log into different files and the server should send smaller chunks. What is the code on the server that gives you this?

  • You can’t separate a bunker, it only provides this data this way. It’s an on-board application, I don’t have access to the code.

  • The 3.6 minutes are up to the.log console or until it appears on the page?

  • 3.6 is until the.log console displays this data so that I can manipulate and display it on the page. the page loads normal, 1ms and is waiting for the data of the request.

  • These data are Bunker’s temperature, so I can only use the latest json information. But to have to read the whole file to get only the last information, it is impossible.

  • You have a server or the page has static html?

  • I have a server.

  • 1

    You could do it like this: Make the server fetch that x file in x minutes, process it and save only what you need in another file or memory. So your Javascript will fetch what you need from your server that has cached what you need, already reduced. Worth a try.

  • I will try this here, but I think it will not serve the problem is the bunker that only sends data at 25 kbps, because as it is a local network 4 megas it would download super fast. But thanks.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.