Given the following JSON object:
var var_affectedAreas = {
? ? ‘areaCount’ : 6,
? ? ‘areasList’: [
? ? ? {‘enum’: ‘FILE’, ‘val’: ‘F’},
? ? ? {‘enum’: ‘REGISTRY’, ‘val’: ‘R’},
? ? ? {‘enum’: ‘PROCESS’, ‘val’: ‘P’},
? ? ? {‘enum’: ‘MEMORY’, ‘val’: ‘M’},
? ? ? {‘enum’: ‘NETWORK’, ‘val’: ‘N’},
? ? ? {‘enum’: ‘OTHER’, ‘val’: ‘O’}
? ? ]
};
You would think (and rightly so, at least under Firefox) that you would be able to access data in this object via the following:
areaCell = var_affectedAreas.areasList[var_areasCount].enum;
areaCell = eval(“var_affectedAreas.areasList[” + var_areasCount + “].enum”);
areaCell = eval(“var_affectedAreas.areasList[‘” + var_areasCount + “‘].enum”);
However, IE7 does not like that syntax and throws syntax errors.
The following syntax works under both IE7 and Firefox.
areaCell = var_affectedAreas[“areasList”][var_areasCount][“enum”];