• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED JSON read help

D

danastock

Guest
Hello all,

I hope you are well.

I am trying running an API into my game, but I have run into an issue with game maker where it doesn't want to read numbered folders. Can anyone shed light into whether I am doing something wrong, or is this a GM limitation? See below reference.

Thanks

Screen Shot 2020-07-31 at 12.06.32 pm.png


var list = ds_map_find_value(resultMap, "eventsData");
var list2 = ds_map_find_value(list,"0");
global.hist_div_price_00 = ds_map_find_value(list2, "amount");
 
Last edited by a moderator:

Nidoking

Member
The picture shows the number 0 (zero), while your code shows the string "0", which is not the number 0. Maybe you should try changing one or the other.
 
D

danastock

Guest
The picture shows the number 0 (zero), while your code shows the string "0", which is not the number 0. Maybe you should try changing one or the other.
Thanks for your reply,

I have tried putting it as a number, but I have the same issue.

I have tried all of the below
var list2 = ds_map_find_value(list,0);
var list2 = ds_map_find_value(list,"0");
var list2 = ds_map_find_value(list,[0]);

Its sounding like a limitation within Game Maker?

Thanks
 
It looks to me like "eventsData" holds a list, not a map, therefore the function call should be a ds_list function not a ds_map function:
Code:
var list = ds_map_find_value(resultMap, "eventsData"); // List now holds a ds_list, not a ds_map
var list2 = ds_list_find_value(list,0); // Naming this list2 is bad practice, as it is actually a map
global.hist_div_price_00 = ds_map_find_value(list2, "amount");
There's no limitation in GMS in regards to JSON notation, at least in this respect, people use it every day. The limitation is in you understanding what structures are stored where within your JSON file.
 
D

danastock

Guest
It looks to me like "eventsData" holds a list, not a map, therefore the function call should be a ds_list function not a ds_map function:
Code:
var list = ds_map_find_value(resultMap, "eventsData"); // List now holds a ds_list, not a ds_map
var list2 = ds_list_find_value(list,0); // Naming this list2 is bad practice, as it is actually a map
global.hist_div_price_00 = ds_map_find_value(list2, "amount");
There's no limitation in GMS in regards to JSON notation, at least in this respect, people use it every day. The limitation is in you understanding what structures are stored where within your JSON file.
Thanks, that helps alot!
 
Top