I have issues with google places
Hey guys, question. I know this might not be the room but I'm curious if any of you know this.
I'm working with google places, when I query the autocomplete it gives me an "array" of this nature:
What is this called? I would like to read up on it?
Thanks
I'm working with google places, when I query the autocomplete it gives me an "array" of this nature:
[country: "South Africa", administrative_area_level_1: "Western Cape", administrative_area_level_2: "Cape Town", locality: "Cape Town", postal_code: "7800", …]When I try data.length on it however, it says 0. I mean, it looks and works like an object. I can do data.country and I get the value, but I can't do data[0], I get undefined....when I do Array.isArray(data) I get true....What is this called? I would like to read up on it?
Thanks
No any search results
You already invited:
1 Answers
Felix
Upvotes from:
@kopahead for example [country:"South Africa", administrative_area_level_1: "Western Cape",..] should be [{country:"South Africa", administrative_area_level_1: "Western Cape"},..]
Each property is a member of an object
Either way you shouldn't be fiddling around with the response or have to rebuild the response. Your better off interating over the returned data and manipulate the iterated object
*iterating over the returned data I meant to say
var response=[ { "country": "South Africa", "administrative_area_level_1": "Western Cape", "administrative_area_level_2": "Cape Town", "locality": "Cape Town", "postal_code": "7800" } ]; var count=response.length; console.write(count);
would give you // 1