For a current Flex project we use JSON to transfer data between the application and the backend. Adobe Labs has a JSON serialization library called corelib that includes MD5 hashing, JSON, and other parsing tools. What if you need just JSON for your Flex or Flash AS3 application development?
There is already a JSON ActionScript file for AS2 available at JSON.org. This file would be great for your older Flash projects and maybe some mobile application development. Initially, I tried to convert this file to AS3, but then I figured someone probably already did this. After some extensive searching and help from Lar (as always), we were able to locate a version of JSON that had been converted to AS3 for a project called VEGAS.
There was no stand alone version of JSON for AS3, we had to extract the JSON pieces from the project files. I did a little touch up for the error messaging, but it is essentially the same JSON for AS2, just updated to work with AS3. In fact, it is by the same author, ekameleon.
I am including all the links to the original source information as well as a stand alone version of the JSON AS3 ActionScript file and Flex Library file with the compiled SWC (called JSONLite). The total size of the JSON AS3 file is 5KB!
To use the file just add the SWC to your Flex Library path. In the MXML file, import the file and call to serialize/deserialize the same way you do with the corelib JSON SWC:
var dataString:String = JSON.serialize(object);
var obj:Object = JSON.deserialize(string);
I don’t support these files, I am just passing the information along and doing some experimentation with other JSON libraries. Also note that using the JSONLite SWC or class file file instead of the corelib file won’t significantly lighten your Flex applications. Flex only compiles the packages and class files you reference in your application from the library. So the post title is a bit misleading because you only shave off that 1KB. However, I have heard from others that this class file is faster than most other JSON parsers which does give it a slight advantage if speed is a concern.