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'];
3 Answers
-
Is the json response a valid json string?
-
yes it is
-
I figured it out
I used
var json = this.responseText; jsonResponse = JSON.parse(this.responseText); Ti.API.info('foo=' + jsonResponse.responseData.results[0].title);