Map, json, typedef

Anyone with experience in formating an json to have info about an Map<string,Arrary<Array>>
I made this but dont know if is correct:

item.json

{
"dic":
    [
    {
     "name": "posion",
     "map": [
     [0,0,6,6,6,6,0,0], 
     [0,0,0,6,6,0,0,0], 
     [0,0,6,9,9,6,0,0],
     [0,6,9,9,9,9,6,0],
     [0,6,9,9,9,9,6,0],
     [0,6,9,9,9,9,6,0],
     [0,0,6,9,9,6,0,0],
     [0,0,0,6,6,0,0,0]
     ]
    }
    ]
}

And it typedef is:

typedef ItemFormat = 
{
    var dic:Map<String,Array<Array<Int>>>;
}

I try this too but dont work:

item.json

{"dic":
  [ { "ColumnName":"posion", "ColumnValue":[
     [0,0,6,6,6,6,0,0], 
     [0,0,0,6,6,0,0,0], 
     [0,0,6,9,9,6,0,0],
     [0,6,9,9,9,9,6,0],
     [0,6,9,9,9,9,6,0],
     [0,6,9,9,9,9,6,0],
     [0,0,6,9,9,6,0,0],
     [0,0,0,6,6,0,0,0]
     ] },
    { "ColumnName":"door", "ColumnValue":[
     [6,6,6,6,6,6,6,6], 
     [6,2,2,2,2,2,2,6], 
     [6,2,2,2,2,2,2,6],
     [6,2,2,2,2,2,2,6],
     [6,2,11,2,2,2,2,6],
     [6,2,2,2,2,2,2,6],
     [6,2,2,2,2,2,2,6],
     [6,2,2,2,2,2,2,6]
     ] } ]
}

Does it work better if you use "dic": { } instead of "dic": [ { } ]?

I’m not sure there’s a direct parallel to Map, but an object type instead of an array might be preferable

I create the Map like this:

var map1:Map<String, Array<Array<Int>> = 
["posion"=> [[0,0],[0,0]], "door"=>[[0,0],[0,0]]];


Then i call this to format to json:

trace(Json.stringify(map1));

in the *.json i copy the trace, is this right?

Yes object is cool (:slight_smile:

but I want to call my array like this:

public function getdc(name:String):Array<Array<Int>>
    {
        return _dc[name];
    }

_dc is the Map

Does it work to create the object in Haxe, stringify, then try and convert back to Haxe? I have a feeling Maps are not preserved if you do this, but its worth the try if you haven’t :slight_smile:

they are not preserved ):