Skip to main content
CEJLLC
Known Participant
January 6, 2020
Answered

How Do I Get My JSON Data to Change Over Time

  • January 6, 2020
  • 1 reply
  • 1380 views

I have a JSON file that is driving text layers.  I need the data to change over time to reflect the changes in the JSON file [at 9:00 am we made 33 sandwiches for example, at 9:05 we made 15]

 

What the variable be?  Fairly new to expressions BTW

 

 

This topic has been closed for replies.
Correct answer Justin Taylor-Hyper Brew

Unable to test exactly without your JSON file, but you could use the linear function to interpolate between 2 sets of start/end values (time and your sales list) like this:

 

eval("var sales="+footage("csvjson01.json").sourceText);
var index = linear(time, 0, thisComp.duration, 0, sales.length-1);
index = Math.round(index);
sales[index].Date;

1 reply

Justin Taylor-Hyper Brew
Community Expert
January 7, 2020

So you're saying you want the text layers to move to the next JSON entry at a certain point in time? Can you share your current AE project and expression setup?

CEJLLC
CEJLLCAuthor
Known Participant
January 8, 2020

 Thank you for the reply.  I am unable to attach the entire JSON file.  However, there are 240 records of the "groups" as seen in the smippet of the initial post.  Below is the script that drives the source text.  A script was submitted that worked to change the "values" over time [underlined].

 

eval("var sales="+footage("csvjson01.json").sourceText);

sales[0].Date;

dur = 1; //Duration, in seconds, of each value
idx = Math.floor(time/dur);
(idx < sales.length) ? sales[idx].Date : sales[sales.length-1].Date;

 

This works.  However, if there are less records than frames in the timeline the last record holds for the balaance of the remaining time.   It would be excellent if the time "adjusted to fit" as the JSON filw will change from day to day but hey, this works.

 

Again, thank you.

 

Cutter

 

FYI:  I could not figure out how to attach the AF file.  Here is an image:

 

Justin Taylor-Hyper Brew
Community Expert
January 8, 2020

Unable to test exactly without your JSON file, but you could use the linear function to interpolate between 2 sets of start/end values (time and your sales list) like this:

 

eval("var sales="+footage("csvjson01.json").sourceText);
var index = linear(time, 0, thisComp.duration, 0, sales.length-1);
index = Math.round(index);
sales[index].Date;