-
Refer to JSON data by index AND attribute name
Hey all, I’m trying to work with JSON data and referring to the data by both index and attribute name. I tried a couple different methods but I’m not able to get it to work. I’m guessing it’s a syntax thing but I’m not sure. Any help is appreciated!
Example JSON:
{
“item1”: {
“name”: “Item 1 Name”,
“parameter”: “Item 1 parameter”,
},
“item2”: {
“name”: “Item 2 Name”,
“parameter”: “Item 2 parameter”,
},
“item3”: {
“name”: “Item 3 Name”,
“parameter”: “Item 3 parameter”,
}
}expression method #1
myData = eval(footage(“sample.json”).sourceData);
myData.item1.name; // works
myData[0].name; //doesn’t workexpression method #2
footage(“sample.json”).dataValue([0, 0]); //works
footage(“sample.json”).dataValue([0, name]); //doesn’t work