ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Using layer name in expression with json file

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jason Reed
Using layer name in expression with json file
on Apr 30, 2018 at 8:13:17 pm

Hi! New to this, but I've been searching for hours and haven't found an answer - apologies if this has been covered before.

data = footage("trump approval ratings.json").sourceData
outlet=thisComp.name;
r1=data[outlet].February;
max=1080;
min=1;
r1a=((max-min)/100)*r1;
r1new=max-r1a;
[value[0], [r1new]]


The JSON data is set up as follows -

"ID": 0,
"Name": "Fox News",
"February": 43,
"March": 45,
"April": 44},


My problem is that I'd like to use the layer name within the comp to call the month data, but I keep running into syntax errors. For example - the above snippet works as is, and calls up the data from the right outlet. I've named my layer February and tried to use the following code without success.

data = footage("trump approval ratings.json").sourceData
outlet=thisComp.name;
month=thisLayer.name;
r1=data[outlet].[month];
max=1080;
min=1;
r1a=((max-min)/100)*r1;
r1new=max-r1a;
[value[0], [r1new]]


What am I doing wrong?


Return to posts index

Dan Ebberts
Re: Using layer name in expression with json file
on Apr 30, 2018 at 8:37:53 pm

Try it without the dot:

r1=data[outlet][month];


Dan



Return to posts index

Jason Reed
Re: Using layer name in expression with json file
on Apr 30, 2018 at 8:51:03 pm

Thank you so much, Dan!

When I use the "February" it needs the period, but not when I'm using a variable - what is the reason for that? Just curious, and thanks again, this will make updating this file much easier in the future.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]