ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

AE Scripting: JSX parsing JSON file already in Project

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Quba Michalski
AE Scripting: JSX parsing JSON file already in Project
on Nov 20, 2018 at 12:16:49 am

Hey,

I am working on a project which requires me to automate creation of comps and layers based on a JSON file. I managed to successfully write a JSX script that reads an external JSON file and does the job, but I was wondering: Is there a way to JSX-parse a JSON file that has already been imported as footage? All my attempts so far result in json2.js library returning errors...

Quba Michalski
qubahq.com


Return to posts index

Scott McGee
Re: AE Scripting: JSX parsing JSON file already in Project
on Nov 23, 2018 at 1:12:37 pm

Unsure what you are trying to do, but if you are in cc2018 or higher.

This is an example of how you access the data from a JSON file that you bring into after effects.

txt = footage("TEST.json").sourceData;
txt.Name

but as for json2.js that's a script job, as far as I'm aware you can't do that in after effects.

Hope that helps


Return to posts index

Quba Michalski
Re: AE Scripting: JSX parsing JSON file already in Project
on Nov 24, 2018 at 3:25:36 am

What I am trying to do cannot be achieved with expressions. I am looking to change the name of the composition. More precisely - to duplicate master composition hundreds of times, and give each new comp a name from a JSON file.

Again - I have no problem doing it by reading an external file, but wondering if it could be achieved with a JSON already imported as footage.

Quba Michalski
qubahq.com


Return to posts index


Scott McGee
Re: AE Scripting: JSX parsing JSON file already in Project
on Nov 24, 2018 at 9:02:10 am

Ah, in that case.

No.

Alterations to comp and layer names can only be achieved via script. Or as far as I'm aware, but I'm pretty confident that can only be done by script.


Return to posts index

Quba Michalski
Re: AE Scripting: JSX parsing JSON file already in Project
on Nov 25, 2018 at 12:04:30 am

Once again - my question was not whether expressions can change the comp name.

My question was: Can JSX Script (File > Scripts) read a JSON file already imported into as a footage - and if so: how?

Quba Michalski
qubahq.com


Return to posts index

Scott McGee
Re: AE Scripting: JSX parsing JSON file already in Project
on Nov 26, 2018 at 9:37:42 am

Completely sorry.

With it being such a new feature being able to import a json file as footage. I honestly don't know.

One would argue that if there was a way to do it via expression. That you should be able to definitely do it via script.

Sorry for misunderstanding, but I think with it being a new feature importing json as footage. It's going to be a case of trial and error.

Mathias Moehl on adobe forums tends to be pretty good with that type of thing. If you want to try there, but all I'm find is expressions, or scripts that add expressions to layers to access the information.


Return to posts index


Scott McGee
Re: AE Scripting: JSX parsing JSON file already in Project
on Nov 27, 2018 at 9:00:21 am

Quba

I cracked it, this will work.

You'll have to adapt to get it to work for yourself. I just wanted it to alert an object in my Json to make sure it worked.

var w = new Window("palette","Test",undefined,{resizeable:true});

var btn2 = w.add("button",undefined,"submit");

var file = app.project.selection[0].file;
file.open("r");
var jsonString = file.read();
file.close();

var Obj = JSON.parse(jsonString);

btn2.onClick = function(){
alert(Obj.Name);
};

w.show();


Mathias helped me, but it didn't like eval, but using JSON.parse fixed it.

So. After all that. Yes it can be done.


Return to posts index

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