Adds a previously created ds_map to a given ds_map.


GML Code Example

ds_map_add_map(id, key, value)

Argument Description
id The id of the map to use.
key The key for the added map.
value The id of the map to add.

Returns: N/A


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.


GML Code Example

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.

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here