因此,这是我的json格式的数据。
{
"New Purchase Orders Created":{
"date":"2018-02-26 14:05:14.000000",
"timezone_type":3,
"timezone":"UTC"
},
"colour":"bg-primary"
}这是我在blade.php中的视图
<ul class="list-group list-group-flush">
@foreach( $notifications as $notification )
<?php $notificationData = json_decode($notification->data, true);?>
@foreach( $notificationData as $key=>$item )
<li class="list-group-item text-white {{ $notificationData['colour'] }}">
@if ($key!='colour')
{{ $key }}<br>
{{ $item['date'] }}
@endif
</li>
@endforeach
@endforeach
</ul>我想把数据放进刀片式服务器。那么我该怎么做呢?

这就是我想要的。
请帮帮忙。谢谢。
发布于 2018-02-26 22:47:38
使用json_decode。这适用于您已经展示过的JSON:
{{ json_decode($json, true)['New Purchase Orders Created']['date'] }}如果每个JSON中的JSON密钥可能不同,请使用array_first()助手:
{{ array_first(json_decode($json, true))['date'] }}如果您将有许多元素,则遍历它们:
$array = json_decode($json, true);
@foreach ($array as $key => $element)
{{ $array[$key]['date'] }}
@endforeachhttps://stackoverflow.com/questions/48991066
复制相似问题