Copy link to clipboard
Copied
Hi all - I'm trying to create a data-driven animation in AE, but am having issues using the .sourceData attribute to read the data from my JSON file (the very first step, argh!).
I'm trying to use values from the JSON to set the size property of an ellipse path.
When I start my expression off with this line:
myData = footage("impact_scores.json").sourceData;
I get this error message:
I can't see that there's anything wrong with my JSON (it's just a simple array of objects - attaching to the post), and I can't seem to find anybody online having the same issue.
Has anybody experienced this problem before or have any ideas on how to troubleshoot? I've tried both expressions engines (javascript & legacy - with legacy the error message is 'Object of type Object found where a Number, Array, or Property is needed'), and I've tested a bunch of different JSONs with the same result.
Here's the expression I want to write once I can get the JSON to link:
myData = footage("impact_scores.json").sourceData;
val = myData[1].01_01_2020
[val,val]
...and I've just updated my AE, so am running version 17.1.1.
Any help would be greatly appreciated!
Copy link to clipboard
Copied
Without any extra processing AE will import the full string. You can't expect it to make any sense of your data pairs when there is no code in place to actually process the list entries. You need to tell AE that one part is the date, the other the actual value.
Mylenium
Copy link to clipboard
Copied
Hi @Mylenium - thanks for responding! I'm not sure I understand – how do I tell AE that?
If it helps, I was following this tutorial: https://www.youtube.com/watch?v=Wkr_XOpsAFU&feature=youtu.be&t=700 – they did not seem to have to specify the structure of the JSON at any point, so I'm a little confused.
Copy link to clipboard
Copied
Just wanted to post that I've figured it out – the properties in my JSON started with a number (they're dates - 01_01_20 etc) and AE didn't like it. I prefixed all of the keys with an X and it's happy again. I probably should have posted more info. Thanks anyway 🙂
Copy link to clipboard
Copied
this should also work, if your keys start with a number:
myData[1]["01_01_2020"]
Also note that my free tool mamoworldJSON might be helpful - it generates the JSON data and the expressions for you which make the data-driven workflows in Ae much more painless:
https://aescripts.com/mamoworldjson/https://aescripts.com/mamoworldjson/
Also, the chapter "Tempaltes & Automation" of my free eBook "Creating Motion Graphics in After Effects that Speaks to Your Brain" contains a ton of information about data-driven animations and automatic layout that might be useful.