Simple JSON decoder for ActionScript 3/Flex

In most of the use cases I come across JSON is my data format of choice for transmitting information between software systems. You might have seen the Adobe corelib JSON classes or even rolled your own, but there is a simpler way using native Javascript because, obviously, JSON is simply a Javascript representation of an native object. How you say? This way I say:

public static function decodeJSON( data:String ):Object {
     return ExternalInterface.call("function(){return " + data + "}");
}

If you run into any problems using the above to decode JSON or you’ve written other cool JSON utilities let me know in the comments.

Tagged :

Leave a Reply