Hey there! I'm currently dealing with a JSON string that has the following structure:
{"2000":["1", "2", "3"],"2001":["1", "2", "3"],"2002":["1", "2", "3"]}
This JSON string is coming from the backend, and my JavaScript function receives it as a parameter named backendData.
When trying to loop through this parameter using the code snippet below, I get the following output:
for (key in backendData) {
alert(key);
}
This will result in three separate alert boxes displaying: 2000, 2001, and 2002.
The issue I'm facing is figuring out how to access the string array associated with each of these "parent" elements. Simply using syntax like key[0]
gives me the character at index 0 of the string, which in all cases is "2".
If anyone has any suggestions or solutions, your help would be greatly appreciated!
Thanks in advance,
/Michael