Forums › Adobe After Effects Expressions › Two approaches: Is one way more efficient using json data?
-
Two approaches: Is one way more efficient using json data?
-
Manuel Moellmann
January 28, 2023 at 9:21 amHey guys, I am working on a data-driven template using text- and color-data based on a .json file on multiple compositions.
Now I am curious if there is a “proper” way to access the .json data. Is it maybe better to first load all of the required data into a global “setup” composition and link everything from there to the elements in multiple compositions? Or should I simply access the json data on every single element itself?
I don’t even know why, but somehow I thought that reading an external footage like the json might by a “heavier” task than getting values from a different composition.
I would appreciate if someone has some input for me on this type of “data handling” topic.
-
Filip Vandueren
January 28, 2023 at 12:32 pmI’ve observed that with very heavy JSON or csv files (thousands of lines) importing and adding to a comp can take a very long time. (For example a multiyear multiregion COVID dataset, or huge GPS tracking data)
In those cases parsing the data myself (either naively using .split() methods or with an external library like papaparse converted to work in expressions) was much faster.
Importing a textfile without letting after effects take any time trying to parse it in import can be achieved by importing it as type “JavaScript” and then accessing the source text of the footage item.
I doubt that there’s a lot of impact on smaller datasets with just a few colors and texts etc.
Adding a data object to a composition actually just prefills everything with expressions that fill in the right coordinates in the dataValue() method, but it is a convenient way to inspect the structure of the data, get the number of rows, and to get the column names etc.
-
Manuel Moellmann
January 28, 2023 at 1:18 pmthanks a lot for your answer. so it doesnt really matter wether to load all of the json data by each individual element on every comp or just first “collect” everything once by storing it in a globally accessed comp and link everything from there to each comp and the corresponding element?
the json itself is just containing around 20-30 lines. nothing extensive. its including title and subtext + colors and a few booleans.
Log in to reply.