It looks like you're new here. If you want to get involved, click one of these buttons!
require("json") local file, blob, comp, data data = { version = "1.1", luaversion = "5.1", tiledversion = "1.0.2", orientation = "orthogonal", renderorder = "left-down", width = 100, height = 50, tilewidth = 16, tileheight = 16, nextobjectid = 188, properties = {}, tilesets = {} } blob = json.encode(data) -- encode table comp = zlib.compress(blob, 9, 8, 15, 9, 0) -- compress json string print("#datasize before write", #comp) file = io.open("|D|data", "wb") -- write binary file file:write(comp) file:close() file = nil file = io.open("|D|data", "rb") -- read binary file comp = file:read() file:close() file = nil print("#datasize after read", #comp) --blob = zlib.decompress(comp, 15) -- recreate json string --data = json.decode(json_blob2) -- recreate table |
Comments