ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

working with JSON values – visualize a car's dashboard

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Stefano Sonntag
working with JSON values – visualize a car's dashboard
on Jun 19, 2019 at 1:25:37 pm

I got a request from my colleague to visualize data which was aquired directly from the interface of an electrical drive city bus. This electical drive engine is new and the client wants to visualize the live battery data (and something more) on his website via splitscreen: a view of the bus driving on the left side and the corresponding live data on the right side, visualized as a digital dashboard.

It is going to look like this:

The data from the bus I'm about to describe was grabbed 50 times per second to a CSV file, which means I have 50 values for each parameter every second to work with.

So the csv file I received looked like this:

After removing everthing I did not need for further work, I got this:

After importing it to After Effects I realised it won't do me no good as long as it's not in JSON file format so I converted the CSV to JSON which then looked like this:

In After Effects it finally looks like I could work with those values:

You see After Effects interprets the JSON file in a two dimensional way: dataValue([x,y]) whereas x represents the number of entry and y stands for the entry's parameter (0 = speed, 1 = engine, 2 = steer, 3 = charge)

Now the most basic thing I want is to have my text layer in after effects just show me the "speed" value. But it needs to change according to this JSON table. So for instance, if I look at frame 0 in my comp the text value should display the very first speed value taken from the first entry of the JSON file (which is called "dataValue([0,0])" in After effects. When I look at frame 136 the text should grab its value from "dataValue([136,0])"

I could pick whip the text layer's source parameter to one of those values, but then I only have one constant value. I somehow need to map it to the second dimension (y) and tell After Effects the first dimension (x) should always be the same as the current frame the comp is in.

Do you have any clue how to write this expression?

Thanks a ton!

Return to posts index

Kalleheikki Kannisto
Re: working with JSON values – visualize a car's dashboard
on Jun 20, 2019 at 6:42:53 am

For animation purposes, I find it easier to convert the CSV into keyframe data in Excel or similar, then export to txt file, copy and paste it as keyframes. That way time is already included.

If you make a couple of keyframes of the kind you need in AE (such a slider for speed) and copy paste them into notepad, you'll see the format. It is very simple, human readable and easy to generate.

Kalleheikki Kannisto
Senior Graphic Designer

Return to posts index

Tomas Bumbulevičius
Re: working with JSON values – visualize a car's dashboard
on Jun 25, 2019 at 8:44:14 am

Hey Stefano,

as far as I understand, you simply need to replace your 'x' of array value to the below:
time / thisComp.frameDuration

This will give you the change of values on every frame, based on json's object array's length. However, make sure to add a check/catch, where it prevents from going out of .jsons range when time progresses further that amount.

On the other hand, not sure what you mean about 'linking y' to some other property. If you elaborate further, it might help. Cheers!

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview

Return to posts index

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