0 Replies Latest reply on Feb 16, 2010 1:20 PM by nbroslawsky

    Unexpected Results Evaluating JSON


      I'm new to using Adobe Air, so I decided to jump right in and port a Javascript/AJAX application over. I did run into a few nuances of the framework that I would like some clarification on:


      1. I'm using jQuery to make an AJAX call to a remote webserver. Since this is after page load, jQuery is unable to eval() the JSON response, I did some overwriting of the jQuery method that handles this response, and I am now handling the eval() in a non-application sandbox function that I created. This function returns the newly-eval()'d object that I want. However, something interesting is happening to my arrays:


      If my JSON looked like

           { "a" : "something", "b" : [1,2,3,4] }


      after I get the object back into my application sandbox, it looks like

           { "a" : "something", "b" : { 0 : 1, 1 : 2, 2 : 3, 3 : 4, "length" : 4 } }


      Therefore, I am unable to use array methods on that "b"object, such as splice, concat, join, etc. Can anyone explain why this is happening? Or, if there is a more-preferred way of handling these kinds of responses, I'd like to hear about it.



      2. This isn't so much a complaint, as it is a request for clarification: most implementations of Javascript/ECMAScript respect the ordering of objects -- however, Air does not. For example, if I returned a JSON object with { "one" : 1, "two" : 2, "three" : 3 }, it would not necessarily be returned to me in that order. I understand that the spec does not specify that ordering should be preserved, but if there are so many implementations that do respect ordering (I believe all major browsers do), why does Air not?


      As I said, I'm new to the framework, so if there are any better ways of handling these cases (or there are any "gotchas" that I should be keeping in mind), please let me know.


      Thanks for the help in advance,