Adding JSON to Adobe After Effects

What is JSON ?

from :

“JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming LanguageStandard ECMA-262 3rd Edition – December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.”

JSON is used a lot by web service as response to replace XML.


Why not using the XML object ?

AE’s XML object is handy, but yet have some weird way to access attribute, which in some case can become problematic. On top that the XML object comes with lots of methods and properties to handle properly an XML.
JSON is pretty much a native Javascript syntax. An object with Key/Values. So you can parse it with any kind of loop or js accessor. It’s easier and faster to handle, and lighter than XML.

from :

Much Like XML

  • JSON is plain text
  • JSON is “self-describing” (human readable)
  • JSON is hierarchical (values within values)
  • JSON can be parsed by JavaScript
  • JSON data can be transported using AJAX

Much Unlike XML

  • No end tag
  • Shorter
  • Quicker to read and write
  • Can be parsed using built-in JavaScript eval()
  • Uses arrays
  • No reserved words


For AJAX applications, JSON is faster and easier than XML:

Using XML

  • Fetch an XML document
  • Use the XML DOM to loop through the document
  • Extract values and store in variables

Using JSON

  • Fetch a JSON string
  • eval() the JSON string

How to add it to AE ?

To add a JSON’s parser and stringifier to AE you could add this file to your script :
Just minify the code and put it at the beginning of your script.

Even better, to make sure the JSON object is always available when you launch AE, you can download this file and put it into the “startup” folder in your script directory. So the JSON object and function will be loaded at AE startup.