I tried to use the JSON method described by iccurd12b42 and I think it's a really great method for localization
First ( just to be sure...) in iccurd12b42 example, root is a ds_map where each key is a language associated to a ds_map , right ?
A point is not clear to me about json_decode() : how correclty manage memory allocation/deallocation ?
Indeed, in the GMS2 manual, we can read the note "GameMaker Studio 2 creates the necessary ds_maps and lists from the JSON, and for cleaning up you only need to delete the
top level map or list and
GameMaker Studio 2 will automatically delete from memory all the maps and lists underneath."
So my understanding is that (still using the example provided by iccurd12b42) we just need to use ds_map_destroy(root) at the end and that's all !
But the example given at the end of GMS2 manual about json_decode() is confusing.
Why are they using ds_map_destroy(map) and ds_list_destroy(list) ?
We are just using ds_map_find_value() and ds_list_find_value() but we have not created them explicitly (by using ds_map_create()..etc..)
here is the example from Yoyo manual:
var resultMap = json_decode(requestResult);
var list = ds_map_find_value(resultMap, "default");
var size = ds_list_size(list);
for (var n = 0; n < ds_list_size(list); n++
{
var map = ds_list_find_value(list, n);
var curr = ds_map_find_first(map);
while (is_string(curr))
{
global.Name[n] = ds_map_find_value(map, "name");
curr = ds_map_find_next(map, curr);
}
ds_map_destroy(map);
}
ds_list_destroy(list);
ds_map_destroy(resultMap);
hope that someone can clarify it to me