I'm dealing with a JSON object that is passed to a script, and the keys are dynamic which makes it hard for me to access the data.
The keys in the JSON object are actually numbers, but no matter how I try to access them, I can't seem to get the desired results.
var countries = {"223":"142,143","222":"23,26,25,24","170":"1,2"};
Initially, I attempted to access the data using the number as a key:
var objKey = 223; (var objKey = "223";) countries.objKey;
After that didn't work, I modified the JSON to have named keys instead:
var countries = {"country223":"142,143","country222":"23,26,25,24","country170":"1,2"};
Even after changing the keys, I still couldn't access the data successfully:
var objKey = "country"+223; (var objKey = "country"+"223";) countries.objKey;
If anyone has any suggestions or advice on how to properly access this data, I would greatly appreciate it.