Skip to main content
Participant
September 8, 2022
Question

Use comp name for json array

  • September 8, 2022
  • 3 replies
  • 237 views

I loaded a JSON file that contains text title

I use array name and it work fine

 

eval("var esm="+footage("csvjson.json").sourceText);
esm[0].MainTitle1;

 

I need to use comp name for array name to use comp name to call array. But it doesn't work.

 

compName = thisComp.name;
eval("var esm="+footage("csvjson.json").sourceText);
esm[0].compName;

 

Please guide me

Thank

 

This topic has been closed for replies.

3 replies

Dan Ebberts
Community Expert
Community Expert
September 11, 2022

I haven't tested this, but try changing the last line to:

eval("esm[0]." + compName);
ShiveringCactus
Community Expert
Community Expert
September 11, 2022

With stuff like this, I wish AE had a dev console like web browsers do.  Try creating a text layer and set the source text to be: compName = thisComp.name

If that works, then do the same, line by line, seeing what is returned.  It might be compName is not a string and so doesn't work on your third line.  (You can conform it to be a string using toString() )

Oh, yeah.  Also double-check your project settings to make sure you're using Javascript and not Extend LegacyScript

Mylenium
Legend
September 9, 2022

thisComp.name is a read only attribute. You cannot change it with expressions. The rest makes no sense if you don't provide the full code where your functions are actually defined, assuming you mean scripting, after all.

 

Mylenium