I have a very specific use case for reading Tiled Map Editor data that doesn’t require the entire libtiled library.
JSON is my preferred format, since it’s really easy to work with in Java. The code I have is working perfectly for raw, uncompressed chunk data that is base64 encoded. As soon as I change the setting in Tiled to gzip or zlib, I start to get completely invalid numbers after a couple of correct tile GID’s are extracted from the base64 decoded string:
RAW/UNCOMPRESSED (Correct data):
Layer Name: Floor
Width, Height: 96,48
Start X,Y: -80,-48
Encoding: base64
Compression:
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1099,1100,1101,691,692,693,694,695,696,697,1207,1208,700,701,
0,0,708,709,1243,1244,1245,713,714,1297,1298,1299,718,719,720,721,
GZIP:
Layer Name: Floor
Width, Height: 96,48
Start X,Y: -80,-48
Encoding: base64
Compression: gzip
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1099,1100,1101,45989871,-1074855936,701,45989871,-1074855936,701,45989871,-1074855936,701,45989871,-1074855936,
1213,79544303,-1074855936,701,45989871,0,0,-1074855936,701,45989871,-1074855936,1213,79544303,-1074855936,1213,45989871,
ZLIB:
Layer Name: Floor
Width, Height: 96,48
Start X,Y: -80,-48
Encoding: base64
Compression: zlib
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1099,1100,1101,45989871,-1074855936,701,45989871,-1074855936,701,45989871,-1074855936,701,45989871,-1074855936,
1213,79544303,-1074855936,701,45989871,0,0,-1074855936,701,45989871,-1074855936,1213,79544303,-1074855936,1213,45989871,
Working source code is here: Paste.ee - Working code for Tiled JSON reader
Exported Raw, gzip and zlib JSON data are here: Paste.ee - Tiled json - raw, gzip and zlib