我正在访问API,并从此API获得JSON响应:
{
"products": [
{
"id": 455968,
"name": "Nike Satire",
"shortName": "Nike Satire",
"priceMin": 199.99,
"priceMax": 199.99,
"discount": 0,
"thumbnail": {
"url": "https://thumbs.buscape.com.br/tenis/nike-satire_600x600-PU6f520_1.jpg",
"height": 600,
"width": 600,
"otherFormats": [
{
"url": "https://thumbs.buscape.com.br/tenis/nike-satire_100x100-PU6f520_1.jpg",
"height": 100,
"width": 100
},
{
"url": "https://thumbs.buscape.com.br/tenis/nike-satire_200x200-PU6f520_1.jpg",
"height": 200,
"width": 200
},
{
"url": "https://thumbs.buscape.com.br/tenis/nike-satire_300x300-PU6f520_1.jpg",
"height": 300,
"width": 300
},
{
"url": "https://thumbs.buscape.com.br/tenis/nike-satire_600x600-PU6f520_1.jpg",
"height": 600,
"width": 600
}
]
},
"hasOffer": 2
},
{
"id": 611192,
"name": "Nike Air Vapor Ace",
"shortName": "Nike Air Vapor Ace",
"priceMin": 229.99,
"priceMax": 229.99,
"discount": 0,
"thumbnail": {
"url": "https://thumbs.buscape.com.br/tenis/nike-air-vapor-ace_600x600-PU95378_1.jpg",
"height": 600,
"width": 600,
"otherFormats": [
{
"url": "https://thumbs.buscape.com.br/tenis/nike-air-vapor-ace_100x100-PU95378_1.jpg",
"height": 100,
"width": 100
},
{
"url": "https://thumbs.buscape.com.br/tenis/nike-air-vapor-ace_200x200-PU95378_1.jpg",
"height": 200,
"width": 200
},
{
"url": "https://thumbs.buscape.com.br/tenis/nike-air-vapor-ace_300x300-PU95378_1.jpg",
"height": 300,
"width": 300
},
{
"url": "https://thumbs.buscape.com.br/tenis/nike-air-vapor-ace_600x600-PU95378_1.jpg",
"height": 600,
"width": 600
}
]
},
"hasOffer": 1
}
]
}
在视图中,我试图将此信息显示为:
<div class="container container-margin">
<div class="list-group">
@foreach($produtos->products as $t)
<a href="{{ $t->id }}" class="list-group-item"><img src="">{{ $t->name }} - from {{ money_format('%n',$t->priceMin) }} to {{ money_format('%n',$t->priceMax) }}</a>
@endforeach
</div>
</div>
我的问题是:如何显示缩略图网址?
我尝试了以下方法:
{{$ t-&gt; thumbnail-&gt; url}}
{{$ t ['缩略图'] ['url']}}
@foreach($ t-&gt;缩略图为$ v){{$ v-&gt; url}} @endforeach
在试图抚养孩子的孩子时似乎没什么用。
答案 0 :(得分:0)
您应该将json数据转换为数组,然后根据需要使用它。 请点击此处查看更多详细信息: