abstract EncodedString(Array<Int>) to Array<Int> {
function new(data : Array<Int>) {
this = data;
}
@:from
static function decode(str : String) {
var compressed = haxe.crypto.Base64.decode(str);
var raw = haxe.zip.Uncompress.run(compressed);
var data:Array<Int> = [];
for (i in 0...Std.int(raw.length/4)) {
var value = raw.getInt32(i*4);
data.push(value);
}
return new EncodedString(data);
}
}
I would expect this to cast the string in the JSON file to an EncodedString, such that I could do the following:
var data:Array<Int> = tiled.TiledJSON.parseFile("path").layers[0].data; // parseFile simply uses haxe.Json.parse
trace(data);
However, this results in the original string in the file being traced, rather than an integer array. Trace data[0] results in "Invalid array access". This is running in the Haxe 3.4.3 interpreter. Can I not expect this to work in the interpreter (I have yet to test other targets)?