Streaming Parsers (JSON/XML) for AS3/Flex/Adobe AIR application Streaming Parsers (JSON/XML) for AS3/Flex/Adobe AIR application json json

Streaming Parsers (JSON/XML) for AS3/Flex/Adobe AIR application


Yup.

Have a look at the AS3 Corelib: http://code.google.com/p/as3corelib/

It's an Adobe library. There should be more info on labs.adobe.com.

I did have an issues with the RSS parser on the date format, but other than that, everything seemed fine.

Goodluck!


The current AIR release (v2.5) bundles a newer WebKit that has native JSON support, via JSON.stringify() and JSON.parse().


You could potentially use a URLStream instance to progressively download the data from a remote network, then decode the JSON result when enough data is available.

Something like this (not tested, just to give you an idea):

var stream:URLStream = new URLStream();stream.addEventListener( ProgressEvent.PROGRESS, handleProgress );stream.load( new URLRequest( "/path/to/data" ) );function handleProgress( event:ProgressEvent ):void{    // Attempt to read as much from the stream as we can at this point in time    while ( stream.bytesAvailable )    {        // Look for a JSONParseError if the JSON is not complete or not        // encoded correctly.        // Look for an EOFError is we can't read a UTF string completely        // from the stream.        try        {            var result:* = JSON.decode( stream.readUTF() );            // If we're here, we were able to read at least one decoded JSON object            // while handling this progress event        }        catch ( e:Error )        {            // Can't read, abort the while loop and try again next time we            // get download progress.            break;        }    }   }