Chapter 7. Data Transfer Additions

A robust application development platform needs a robust set of data transfer options. With the introduction of root level XML support along with the first release of Adobe AIR, developers could take advantage of any XML-based format within their applications. AIR 3 adds support for a native JSON handler and some great enhancements when working with sockets in communicating with various systems.

Native JSON (JavaScript Object Notation) Support

JavaScript Object Notation (JSON) is a hugely popular way of transporting structured data sets into and out of applications that run within AIR applications. Ever since ActionScript 3.0 was introduced, there have been third-party support libraries which allowed developers to use JSON in their projects quite easily; however, this is costly in terms of performance, since it was never a core function of AIR itself.

Note

JSON is a top level class, similar to the XML or Array classes present in ActionScript. As such, they do not need to be imported in order to be used within an application.

The following JSON object describes a person through a series of name value pairs. Notice that objects can be nested and that this syntax can even include array structures. It is incredibly flexible.

{ "firstName": "Joseph", "lastName": "Labrecque", "address": { "streetAddress": "2199 S. University Blvd.", "city": "Denver", "state": "CO", "postalCode": "80208" }, "phoneNumber": [ { "type": "work", "number": "303.871.6566" }, { "type": ...

Get What's New in Adobe AIR 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.