Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Parsing JSON based on layer name

  • Parsing JSON based on layer name

    Posted by Chris Gosling on October 20, 2017 at 8:14 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]

    Chris Gosling replied 8 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 20, 2017 at 8:22 pm

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

    myData[month]

    Dan

  • Chris Gosling

    October 20, 2017 at 8:32 pm

    Thanks Dan!!
    Written while kicking myself….

    Chris

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy