With this function you can assign a (previously created) ds_list 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 a list added in this way, destroying the parent map will also destroy the contained lists and free their memory.


ds_map_add_list(id, key, value)

参数 描述
id The id of the map to use.
key The key for the added list.
The id of the list to add.




var j_list = ds_list_create();
ds_list_add(j_list, health);
ds_list_add(j_list, lives);
ds_list_add(j_list, score);
var j_map = ds_map_create();
ds_map_add_list(j_map, "list", j_list);
var j = json_encode(j_map);

The above code will create a list and populate it with the various values of global variables. This list is then "nested" within a ds_map, and the map is then encoded into a JSON string, before the map is destroyed, removing it, and any lists it contains, from memory.