Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

JSON parsing iPhone Vs. Android

So I was informed about the url encoding that Android DOES NOT do for xhr. Now I am at a stage where my webservice is returning a result in JSON format. Displays fine in iPhone and I can parse it.

It is of the format:

{Result = ({Distance=5;Price=25.00;Link=www.google.com},{Distance=12;Price=34;Link=www.msn.com});}

This is not parsing at all in the Android env.

Do i need the JSON message to be in a particular format?

I am using JSON.parse.

On Android my result is:

{"Result":"[Ljava.lang.Object;@438c3618"}

Any suggestions?

— asked August 9th 2010 by Johnny Basu
  • android
  • iphone
  • json
  • json.parse
0 Comments

1 Answer

  • What you have there is not a valid JSON string

    To be valid should be something like:

    {"Result" : [ {"Distance":"5","Price":"25.00","Link":"www.google.com"},{"Distance":"12","Price":"34","Link","www.msn.com"}] }
    
    — answered August 9th 2010 by Dan Tamas
    permalink
    2 Comments
    • Thanks Tamas, I was going through the QA's and saw someone use the eval function on this.responseText. That's where it threw things off. JSON.parse seems to be working now.

      — commented August 10th 2010 by Johnny Basu
    • Hi @Dan Tamas .. i have also same issue .. My json is valid and it is display prefectly in iphone but not working in Android ..

      — commented February 29th 2012 by Hitarth Parmar
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.