我知道这对你们中的一些人来说可能看起来很基础,但我正在尝试用 jquery 迭代一个 json 对象,如何访问每个生产者的每个网页名称。请帮忙!底部是我的代码,欢迎提供任何帮助。
{
"producers": [
{
"producer": {
"id": "1",
"name": "Radosa",
"address": " Grenvägen 1-3",
"zipcode": " 577 39",
"district": " Hultsfred",
"webpage": [
{
"name": "waste",
"purpose": "sample "
},
{
"name": "Ultra Worker",
"purpose": "Posao"
}
],
"logoURL": "../producenter/images/ema.png",
"latitude": "57.4999",
"longitude": "15.828"
}
},
{
"producer": {
"id": "2",
"name": "Marko",
"address": " Grenvägen 1-3",
"zipcode": " 577 39",
"district": " Hultsfred",
"webpage": [
{
"name": "Sample name",
"purpose": "sample purpose"
},
{
"name": "Sample name",
"purpose": "sample purpose"
}
],
"logoURL": "../producenter/images/ema.png",
"latitude": "57.4999",
"longitude": "15.828"
}
}
]
}
$.each(data.producers, function(key, value) {
console.log(value.producer); ------ this works,
console.log(value.webpage.name); ------ this don't work. How to reach this value?
});