Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Are there any stream-reading, parsing libraries available for json or xml formats in AS3? I'm setting up a long-polling application, using URLStream/URLRequest. I do not have control over the data I'm receiving other than a choice between formats. I'd like to have a parser that can handle fragments at a time, which would allow me to trigger custom events when certain complete fragments become available. Thoughts? What are current AIR applications doing to handle this?

Sample API:

var decoder:StreamingJSONDecoder = new StreamingJSONDecoder();
decoder.attachEvent("onobjectavailable", read_object); 

while (urlStream.bytesAvailable) 
{
  decoder.readBytes(get_bytes(urlStream)); 
}

2 Answers

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!

like image 169
George Profenza Avatar answered Dec 03 '25 19:12

George Profenza


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

like image 40
Chris Dolan Avatar answered Dec 03 '25 20:12

Chris Dolan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!