Any particular advantage to using json over xml with Flash Any particular advantage to using json over xml with Flash json json

Any particular advantage to using json over xml with Flash


JSON is typically a more efficient data encoding method than XML. This would matter if download time mattered to your application.

Another consideration is whether E4X query syntax has compelling advantages for your particular usage. It may be that you can do what you want by iterating over the results of a single query line, and the equivalent ActionScript code would be longer when interating over parsed JSON.

I would also consider whether this app has to interact with JavaScript code, such as because the Flash app lives in a browser and has to communicate with other things on the page. If so, I'd go with JSON, because dealing with XML in browser JS (as opposed to modern JS 1.8 with E4X) is much harder than dealing with JSON.


XML is a bunch of data. It's 90% hypertext and 10% data.

JSON has 2 major advantages here:

  1. It is smaller. That means that less bandwith will be used (better response times, excelent for AJAX)
  2. It is a subset of JavaScript, that means that to parse it all you need is a call to the eval() function, like:

    result = eval(resultStr); var age = result.clients[2].age;

I definetely recoomend JSON.


Yet Another major advantage is parsing speed. Parsing large amounts of xml is very slow especially with the E4X, and even more so on mobile devices. I've observed about a 10 fold speed increase using json instead of xml to represent same data. In this case the data was 1.5 MB zip compressed.