I’ve created a little map via PyxelEdit, it is 640×400 in size using 8×8 tiles (so 80×50) and I’m using 3 layers, I’ve exported it into JSON format and when trying to parse it is taking over a second:
[ crayon - 5cb997dc359db105950784 inline = "true" ] Local json : = LoadString ( "asset::levels/" + mapFileName + ".json" )
Local st : = Millisecs ( )
jsonData = JsonObject . Parse ( json )
Local et : = Millisecs ( ) - st
Print "JSON Parser took " + et + "ms"
[/crayon]
Here is a subset of the JSON:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[ crayon - 5cb997dc359e2580993827 inline = "true" ] {
"tileshigh" : 50 ,
"tileheight" : 8 ,
"tileswide" : 80 ,
"tilewidth" : 8 ,
"layers" : [
{
"tiles" : [
{
"x" : 0 ,
"rot" : 0 ,
"y" : 0 ,
"index" : 0 ,
"tile" : - 1 ,
"flipX" : false
} ,
{
"x" : 1 ,
"rot" : 0 ,
"y" : 0 ,
"index" : 1 ,
"tile" : - 1 ,
"flipX" : false
} ,
{
"x" : 2 ,
"rot" : 0 ,
"y" : 0 ,
"index" : 2 ,
"tile" : - 1 ,
"flipX" : false
} ,
[/crayon]
If I export to XML and parse it via tinyxml it only takes around 300ms.
The JSON is pretty big though over 2MB in size, but even compressed its slow.