3 ms·
Make rows 1 dimensional. You don’t need the second dimension, it’s implied by header length. Once you do this, the JSON gzips down to about the same size as CSV
by earthboundkid 5y ago
Make rows 1 dimensional. You don’t need the second dimension, it’s implied by header length. Once you do this, the JSON gzips down to about the same size as CSV, according to the last time I tested this IIRC.
- dragonwriter 5y agoHeck, you could do a single 1-D list (no object), and just give the header count as the first element, which would be even more compact.
- earthboundkid 5y agoSmart idea.
- anonytrary 5y agoI edited-in the "2DArray" because I thought it was confusing... But you're right, just calculate offsets. The dominating term is still quadratic, and the term you mentioned is linear. It could be worth it for a scaled org like Google! I wonder which parses faster. I guess CSV does but then the consuming code would still have to parse the strings into JS primitives...
- earthboundkid 5y agoI haven't tested this, but my guess is that because the browser built in JSON.parse will be faster than whatever CSV parser you can write in JS just because it's precompiled to native code. Then the question becomes how long does it take to do the unpacking loop, but it should be pretty quick. I'd love it if someone did a benchmark though.