-
• #2
I'm afraid you can't, since heatshrink compresses only a sequence of bytes, not a structure.
If you want to compress it and get the data back, you'll need to compress the JSON, so:
schedule = require("heatshrink").compress(require("Storage").read("CustomSchedule.json"));
However this may be counterproductive.
require("Storage").read
effectively 'memory maps' the JSON that's in flash memory, so it doesn't actually use up any RAM when it's sitting there as a string.It's only when you decode it with
JSON.parse
that it ends up using a bunch of memory
I compress an object:
schedule = require("heatshrink").compress(JSON.parse(require("Storage").read("CustomSchedule.json")));
Printing the value of schedule returns
new Uint8Array([0, 2]).buffer
.I then decompress using
console.log(require("heatshrink").decompress(schedule));
and getnew ArrayBuffer(2)
.How can I convert the ArrayBuffer back to an object?