3 ms·
Does anyone know a JSON parser that parses an ArrayBuffer instead of strings? [1] JSON.parse() only accepts strings. The library that the article recommends a
by jannes 9y ago
Does anyone know a JSON parser that parses an ArrayBuffer instead of strings? [1]
JSON.parse() only accepts strings.
The library that the article recommends also uses XMLHttpRequest with strings. [2]
The reason I'm asking is the maximum string length in 32-bit Chrome.
[1]: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequ...
[2]: https://github.com/eBay/jsonpipe/blob/master/lib/net/xhr.js https://github.com/eBay/jsonpipe/blob/master/lib/net/xhr.js
- matharmin 9y agoIf you want to parse more than 4GB of JSON in a browser, ArrayBuffer versus string isn't the most important criteria - you shouldn't parse a 4GB ArrayBuffer as a single chunk either. You can always convert between an ArrayBuffer and a string, but you'll want to compare parsers according to the ability to stream, as well as performance and memory efficiency.
- DvdGiessen 9y agoYou could look into streaming parsers such as Oboe.js, which specifically support the use case of parsing JSON tree's larger than the available RAM[0]. Then again, when you're loading such huge JSON files into a 32-bit instance of Chrome, it is likely you should look for a totally different solution to your problem. [0]: http://oboejs.com/examples#loading-json-trees-larger-than-the-available-ram http://oboejs.com/examples#loading-json-trees-larger-than-th...