Titanium Community Questions & Answer Archive

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

Parsing Json

I am trying to parse a JSON response form google local search I have used

var i = -1;
        var aAddress = json["responseData"].results;
        for(var a=0;a<aAddress.length;a++) {
            // We have more than one line by address
            aAddressLines = aAddress[a].addressLines;
            for(var l=0;l<aAddressLines.length;l++) {
                alert( "Address number " + (a+1) + ", line number " + (l+1) + " is : " + aAddressLines[l] );
            }
        }

in a webpage and it works fine I cannot get it to process in a titanium
Anyone know how I can do this I am trying to get the addresses in this format

var m0 = [37.3317,-122.340145,'3/27/2010 22:13','Jumping bush cricket','1521 1st Ave Seattle'];

— asked April 26th 2010 by Laney Dale
  • iphone
  • json
  • parse
0 Comments

3 Answers

  • Is the json response a valid json string?

    — answered April 26th 2010 by Dan Tamas
    permalink
    0 Comments
  • yes it is

    — answered April 26th 2010 by Laney Dale
    permalink
    0 Comments
  • I figured it out

    I used

    var json = this.responseText;
                jsonResponse = JSON.parse(this.responseText);
    
                Ti.API.info('foo=' + jsonResponse.responseData.results[0].title);
    
    — answered April 26th 2010 by Laney Dale
    permalink
    0 Comments
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.