ActionScript 3 JSON Library Now Available

| 4 Comments | No TrackBacks

I'm happy to announce that my JSON library has been made publicly available through labs. JSON stands for "JavaScript Object Notation" and is a lightweight data exchange format, sort of like WDDX on a diet.

You can download the JSON library as part of the core ActionScript 3 library.

Usage is as follows:

// import the JSON library from the core serialization package
import com.macromedia.serialization.json.JSON;

// Encode a native ActionScript object as a JSON string
var jsonString:String = JSON.encode( someValue );

// Decode a JSON string into a native ActionScript object
var value:* = JSON.decode( jsonString ); 

If you run into any problems with it, let me know. It passed all of the unit tests, but there's always a chance that a test case is missing and there's a hidden bug somewhere. I'm interested in hearing any feedback you may have!

Tags: , , , , , ,

No TrackBacks

TrackBack URL: http://www.darronschall.com/mt/mt-tb.cgi/97

4 Comments

Here's the JSON test suite:

http://labs.macromedia.com/svn/flashplatform/?/projects/corelib/trunk/src/actionscript3/com/macromedia/serialization/json/tests/JSONTest.as

Numbers could use some more tests. What happens if you run 6.02e23 through an encode/decode? =)

Thanks Robert, I'll take a look at it and update the code in the repository as soon as I can find time to fix it.

No worries, it's just a simple tweak to readNumber() inside of the tokenizer:

http://labs.macromedia.com/svn/flashplatform/?/projects/corelib/trunk/src/actionscript3/com/macromedia/serialization/json/JSONTokenizer.as

I'm not checking correctly for exponents. I'll fix it tomorrow if I can squeeze in the time.

Leave a comment



About this Entry

This page contains a single entry by darron published on February 28, 2006 9:19 AM.

E4X: Predicate Filtering with Regular Expressions was the previous entry in this blog.

How to use FlexUnit with FlexBuilder 2 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Archives

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.02