0

I am trying to load and parse a 1GB .JSON in some JavaScript to be run locally in a user's browser.

It is too big for FileReader.readAsText().

I am able to read it in with FileReader.readAsArrayBuffer() but then have to chunk it to convert from a Uint8 array to an array of chunked strings which is then too long to .join() for parsing.

At the moment the only solution I can see is to chunk the strings into separate JSON objects, parse them individually and then merge the parsed objects.

I'm new to JavaScript so suspect I am going about this an inefficient and unconventional way. Do you know of a better way to locally read and parse such a large .JSON file in JavaScript in a browser?

  • 1
    Make a [web worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) and have that parse the JSON file. – kelsny Sep 23 '22 at 23:05
  • 1
    Does this answer your question? [How to read any local file by chunks using JavaScript?](https://stackoverflow.com/questions/50254537/how-to-read-any-local-file-by-chunks-using-javascript) – Emiel Zuurbier Sep 23 '22 at 23:07

0 Answers0