Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var _root_list = ds_list_create(); // list containing each wishlist created
- var wishlist_size = ds_grid_height(wishlist_grid); // get the number of wishlists created
- for(var i=0;i<wishlist_size;i++) // loop through every wishlist in the grid
- {
- // create submap that contains "wishlist" and "itemlist"
- var _submap = ds_map_create();
- // create map for the wishlist
- var _map_wish = ds_map_create();
- // get values
- var _name = wishlist_grid[# 0,i]; // wishlist name
- var _owner = wishlist_grid[# 1,i]; // owner id
- // add key/values to wishlist map
- ds_map_add(_map_wish ,"name",_name); // save wishlist name
- ds_map_add(_map_wish ,"owner",_owner); // save owner id of list
- // add wishlist map to the submap
- ds_map_add_map(_submap,"wishlist",_map_wish);
- // save every item in the item list
- var item_list = ds_list_create(); // contains the itemlist
- var item_grid = wishlist_grid[# 2,i]; // get the pointer of item grid associated with the wishlist
- var itemlist_size = ds_grid_height(item_grid); // number of items in the grid
- for(var n=0;n<itemlist_size;n++) // loop through the grid
- {
- // create the map for the item
- var _map_item = ds_map_create();
- ds_list_add(item_list,_map_item); // add the map to the item_list
- ds_list_mark_as_map(item_list,ds_list_size(item_list)-1); // mark it as a map
- // get values
- var _name = item_grid [# 0,n]; // item name
- var _price = item_grid [# 1,n]; // item price
- // add key/values to itemlist map
- ds_map_add(_map_item ,"name",_name); // save item name
- ds_map_add(_map_item ,"price",_price); // save item price
- }
- // add item_list to the submap
- ds_map_add_list(_submap,"itemlist",item_list); // added to submap
- ds_list_add(root_list,_submap); // add the submap to the root_list
- ds_list_mark_as_map(root_list,ds_list_size(root_list)-1); // mark as map
- }
- // wrap the data up
- var _wrapper = ds_map_create();
- ds_map_add_list(_wrapper,"ROOT",_root_list);
- // save as string
- var _string = json_encode(_wrapper);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement