What is JSON ?
from json.org :
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.
from http://www.w3schools.com/json/json_intro.asp :
Much Like XML
- JSON is plain text
- JSON is “self-describing” (human readable)
- JSON is hierarchical (values within values)
- JSON data can be transported using AJAX
Much Unlike XML
- No end tag
- Quicker to read and write
- Uses arrays
- No reserved words
For AJAX applications, JSON is faster and easier than XML:
- Fetch an XML document
- Use the XML DOM to loop through the document
- Extract values and store in variables
- 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 : https://github.com/douglascrockford/JSON-js/blob/master/json2.js
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.