Итак, я ломал голову, пытаясь получить доступ к определенному элементу через цикл for в JS, я рисую пробел.У меня есть объекты JSON с 15 элементами (пример одного ниже. Я пытаюсь получить доступ к элементу "phones" .phone_number, но получаю неопределенное значение. Ниже также мой цикл for.
сейчас я просто консоль, регистрирующая всеэлементы. первые два, .name и адрес возвращаются найти, но это телефоны, которые не возвращаются с результатами.
for(var i=0; i < json.business.length; i++ ){
console.log(json.business[i].name);
console.log(json.business[i].found_at_address.street_line_1);
console.log(json.business[i].phones[i].phone_number);
}
{
"count_business": 15,
"business": [
{
"id": "Business.7146cd10-735f-4710-b145-93b97fe45e07",
"name": "Grace Christian Fellowship",
"industry": [
"Religious, Grantmaking, Civic, Professional, and Similar Organizations"
],
"found_at_address": {
"id": "Location.5c80fbd1-5e5a-4356-9725-5492e3942091",
"location_type": "Address",
"street_line_1": "210 2nd St",
"street_line_2": null,
"city": "Mounds",
"postal_code": "62964",
"zip4": "1144",
"state_code": "IL",
"country_code": "US",
"lat_long": {
"latitude": 37.113098,
"longitude": -89.200842,
"accuracy": "RoofTop"
},
"is_active": true,
"delivery_point": "POBoxThrowback",
"link_to_business_start_date": "2016-11-19",
"link_to_business_end_date": null
},
"current_addresses": [
{
"id": "Location.5c80fbd1-5e5a-4356-9725-5492e3942091",
"location_type": "Address",
"street_line_1": "210 2nd St",
"street_line_2": null,
"city": "Mounds",
"postal_code": "62964",
"zip4": "1144",
"state_code": "IL",
"country_code": "US",
"lat_long": {
"latitude": 37.113098,
"longitude": -89.200842,
"accuracy": "RoofTop"
},
"is_active": true,
"delivery_point": "POBoxThrowback",
"link_to_business_start_date": "2016-11-19"
}
],
"historical_addresses": [],
"phones": [
{
"id": "Phone.46c16fef-a2e1-4b08-cfe3-bc7128b6e19a",
"phone_number": "+16187459424",
"line_type": "Landline"
}
],
"associated_people": [],
"associated_businesses": [
{
"id": "Business.e43f1c0d-ecec-42da-ad1c-76badfdf2dcf",
"name": "Usda Rural Development",
"industry": [
"Administration of Housing Programs, Urban Planning, and Community Development"
],
"relation": "Household"
}
]
},