ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

JSON Data - how to access it from a text layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Juergen Saalmueller
JSON Data - how to access it from a text layer
on Jun 3, 2018 at 4:15:04 am

Hi ,

a bit of a noob question about using data from a file.

I have successfully read in some json data using
json2.js (

and then in the script editor :

var Power = new Array ();
var JsonFile = new File ("C:/path/DataFile.json");
if ("r")){
JsonFile.encoding = "UTF-8";
var Data =;
Power = JSON.parse(Data);

I can see the data within the script editor. For instance Power.alt returns the correct value from the file, a number in this case.

However i'm stuck when i try to display Power.alt in a text layer using eval in the Source Text.

Any ideas how to achieve this would be much appreciated.


Return to posts index

Scott McGee
Re: JSON Data - how to access it from a text layer
on Jun 4, 2018 at 11:32:29 am

Out of curiosity, is there a reason why you are not just using CC2018 that includes the ability to read JSON data.

Return to posts index

Juergen Saalmueller
Re: JSON Data - how to access it from a text layer
on Jun 4, 2018 at 12:03:41 pm

Hi Scott,
I am using 2018 and tried that functionality but it makes preview and rendering unacceptably slow. Having three gauges on the screen animated via expressions changes render time from roughly 7 minutes per minute of footage to an estimated 42 hours per minute. So using expressions is impractical.
Tried to convert to keyframes but cancelled that after it was still running after two hours for a 30 second clip. I suspect the multiple file reads from each frame in each expression cause the delay and was hoping that storing the data in a global array variable and referencing that from the composition would circumvent that problem.


Return to posts index

Scott McGee
Re: JSON Data - how to access it from a text layer
on Jun 4, 2018 at 2:52:14 pm

That's fair enough, my machine was fine with the data, but if it's a burden. Can completely understand.

var name = myObject[0].name;

So you've seen how to pull the info. Add to your script.

I used it this way, but I wouldn't say it's the best. That was to change the layers name and using sourceText to use the Layers name as it's text.

var myComp = app.project.activeItem;
myComp.layer(1).name = name;

if you want to import the value into source text. Same thing

var myComp = app.project.activeItem;

but then you need to use something to reference. Wether you aren't making changes to the layers number

myComp.layer(1).property("Source Text").setValue("Test");;

or if you layers name is always going to be the same.

myComp.layer("layers name").property("Source Text").setValue("Test");

Now you can do this as a for loop expression, but not going to lie, I've not used that in this context and I'm relatively new to this myself, but this should get you started hopefully.

Another way to look at it maybe as well is with keys at the front. Again, I've used that with 2018 but not with a script at all. That could be another way to look at it so you could reference layer based on name.


so it would look more like this

This you could then use in an expression that would again loop through all the layers and if it sees any with that key in as the layer name could use that.

Sorry for the waffle but other than this, I used cc2018.

var name = myObject[0].name;
var myComp = app.project.activeItem;
myComp.layer(1).property("Source Text").setValue(name);

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved