Highlighted

AE unable to read data from an external JSON file using .sourceData

Community Beginner ,
Jun 17, 2020

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:

 

Screenshot 2020-06-17 at 15.07.27.png

 

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! 

TOPICS
Expressions, Scripting

Views

121

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

AE unable to read data from an external JSON file using .sourceData

Community Beginner ,
Jun 17, 2020

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:

 

Screenshot 2020-06-17 at 15.07.27.png

 

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! 

TOPICS
Expressions, Scripting

Views

122

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 17, 2020 0
Most Valuable Participant ,
Jun 17, 2020

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 17, 2020 0
Community Beginner ,
Jun 17, 2020

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.

Get the Course Materials: https://gum.co/animoplex-expressions World of Expressions - Full Playlist: https://www.youtube.com/playlist?list=PLvr5U5ZSt6IzHyvSL...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 17, 2020 0
Community Beginner ,
Jun 17, 2020

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 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 17, 2020 0
Adobe Community Professional ,
Jun 19, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 19, 2020 0