ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Parsing JSON based on layer name

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chris Gosling
Parsing JSON based on layer name
on Oct 20, 2017 at 8:14:54 pm

Ok, so I'm playing around with AE 2018 and the new JSON import functionality, and have run into a problem.

I want to use the layer name to indicate which item from the JSON file to read. But when I try to add a variable calling the the layer name it causes an error.

My JSON file is:
[
{
"City": "Copenhagen",
"Year": 2016,
"Jan": 2,
"Feb": 4,
"Mar": 5,
"Apr": 10,
"May": 16,
"Jun": 19,
"Jul": 21,
"Aug": 21,
"Sep": 17,
"Oct": 12,
"Nov": 7,
"Dec": 4
}
]

The expression I have on the position is below. The problem occurs when I try to change the "monthTemp = myData.Jan" to "monthTemp = myData.month" - where it rightly so, cannot find the "month" entry in the JSON file.

How can I force the "monthTemp" to parse "month" as a variable??

Any help is appreciated.

Chris

month = thisLayer.name;
myData = footage("CPH_temps.json").sourceData[0];
monthTemp = myData.Jan;

temp = linear(monthTemp, 0, 30, 992, 90);

[value[0],temp]


Return to posts index

Dan Ebberts
Re: Parsing JSON based on layer name
on Oct 20, 2017 at 8:22:53 pm

I don't have time to test, but try:

myData[month]

Dan



Return to posts index

Chris Gosling
Re: Parsing JSON based on layer name
on Oct 20, 2017 at 8:32:38 pm

Thanks Dan!!
Written while kicking myself....

Chris


Return to posts index

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