ds_list_mark_as_map

"Marks" a given ds_list position as being a ds_map.

Syntax:

GML Code Example

ds_list_mark_as_map(id, pos);


Argument Description
id The id of the list to mark.
pos The position within the list to mark.


Returns: N/A


Description

This function will "mark" (or "flag") a given position within a previously created ds_list as holding a previously created ds_map. This functionality is designed only for use when encoding JSON strings (which you can create using json_encode) and the complimentary ds map functions.

NOTE: Once a ds_list has had a value within it flagged as another list or map, destroying the list will also destroy the marked lists and maps too. This means that you do not have to manually go through the list contents and destroy the marked data structures individually before destroying the "parent" list.


Example:

GML Code Example

var sub_map = ds_map_create();
 ds_map_add(sub_map, "player", player_array);
 ds_map_add(sub_map, "enemy", enemy_array);
 ds_list_add(j_list, sub_map);
 ds_list_mark_as_map(j_list, 0);
 

The above code creates a ds_map and then populates it with two keys, each containing an array of values. This map is then added into the given ds_list, and the position "marked" as such so that it can be correctly encoded later.


Back: DS Lists



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