views:

387

answers:

3

Well is there?

From everything I've read, it seems like the answer is no,but was wondering if anybody has a differing opinion.

+3  A: 

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.

Warren Young
+1  A: 

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.

Seth Illgard
Parsing JSON with eval() is a security risk. Only do it if you're absolutely sure you can trust the data source. Otherwise, it provides a way for someone else to inject code into your application. Can you say XSS, kids? I thought you could.
Warren Young
A: 

JSON means JavaScript Object Notation ... the definite advantage about JSON is, that it captures objects semantics of ECMAScript (including ActionScript) ... E4X helps a lot to somehow make XML objects feel good within ActionScript but still ...

if i have <node attribute="value"><child/><node>, i cannot really say, what it is ... is child a property? is it an entry to a array of length one? how will i evaluate the nodename node?

a JSON string represents an anonymous actionscript object ... an XML doesn't ...

apart from that, there are the advantages allready mentioned: it is smaller and more lightweight ... and one definitive advantage about JSON is, it can capture numeric and boolean values ... this is not the case for XML ... attrib="123" could mean the string 123 or the integer 123 ... same thing for true, false and null ...

greetz

back2dos

back2dos