Return to Snippet

Revision: 48834
at July 11, 2011 14:18 by chrisaiv


Initial Code
function jsonHandler( e:Event ):void
{
var rawJSON:String= URLLoader(e.currentTarget).data;
var bookStart:String = "[{";
var bookEnd:String = "}]";
	rawJSON = rawJSON.slice( 
		rawJSON.indexOf( bookStart ), 
		rawJSON.lastIndexOf( bookEnd ) + bookEnd.length );
//trace( rawJSON );
var array:Array = JSON.decode(rawJSON) as Array;
trace( array.length );
}

Initial URL


Initial Description
I always have trouble preparing JSON to work nicely with as3corelib.  Here's an example of what I do whenever the array I'm looking for is nested within more JSON. This really isn't for anyone other than myself.

Initial Title
AS3: JSON.decode

Initial Tags
json

Initial Language
ActionScript 3