June 2015
Intermediate to advanced
192 pages
4h 8m
English
Sometimes, you don't want to work with JSON at all, but instead with pure binary data. JavaScript provides the DataView abstraction, which lets you perform typed accesses on an array buffer of memory, such as one obtained from an XMLHttpRequest object.
To begin, you need your data in an ArrayBuffer, such as the one returned by the XMLHttpRequest object. With this, you can create a DataView, and then using that DataArray, create a typed array over the data view to extract just the bytes that you're interested in. Let's see an example.
Here's a simple example:
var req = new XMLHttpRequest(); req.open("GET", url, true); req.responseType = "arraybuffer"; req.onreadystatechange = function ...Read now
Unlock full access