With this function you can assign a (previously created) ds_map to a key within the given ds_map. This function is designed for creating JSON compatible maps which you would then encode using json_encode and should only be used in conjunction with that functionality. If a ds_map has another map added in this way, then destroying the parent map will also destroy the contained maps and free their memory.
ds_map_add_map(id, key, value)
|id||The id of the map to use.|
|key||The key for the added map.|
|value||The id of the map to add.|
var j_map = ds_map_create();
var j_list = ds_list_create();
var sub_map = ds_map_create();
ds_map_add_list(sub_map, "list", j_list);
ds_map_add(sub_map, "array", j_array);
ds_map_add_map(j_map, "map", sub_map);
var j = json_encode(j_map);
The above code will create two ds_maps, and then populate one with a list and an array before adding it into the second, which is then encoded into a JSON string. The map is then destroyed to remove it, and any other maps or lists that it contains, from memory.