我想在有新数据时动态地预测这些数据,如何制作这个数据?
我使用包 laravel-nestedable
这是我的回归json:
[ { " ID":1, "名称":"食品&#34 ;, "蛞蝓":"食品&#34 ;, "子":[ { " ID":2, "名称":"蛋糕&#34 ;, "蛞蝓":"蛋糕&#34 ;, "子":[ { " ID":3, " name":" Rainbow Cake", "蛞蝓":"彩虹饼&#34 ;, "子":[
Get-Content : Cannot find path 'C:\Users\HarmanGrewal\192.168.2.10,' because it does not exist.
At C:\Users\HarmanGrewal\Google Drive\win213\assignment2\assignment2QuestionAnswer1.ps1:13 char:1
+ Get-Content $array1 | export-csv -path "C:\Users\HarmanGrewal\test.tx …
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\HarmanGrewal\192.168.2.10,:String) [Get-Content], ItemNotFound Exception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
Get-Content : Cannot find path 'C:\Users\HarmanGrewal\192.168.2.14,' because it does not exist.
At C:\Users\HarmanGrewal\Google Drive\win213\assignment2\assignment2QuestionAnswer1.ps1:13 char:1
+ Get-Content $array1 | export-csv -path "C:\Users\HarmanGrewal\test.tx …
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\HarmanGrewal\192.168.2.14,:String) [Get-Content], ItemNotFound Exception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
Get-Content : Illegal characters in path.
At C:\Users\HarmanGrewal\Google Drive\win213\assignment2\assignment2QuestionAnswer1.ps1:13 char:1
+ Get-Content $array1 | export-csv -path "C:\Users\HarmanGrewal\test.tx …
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (C:\Users\HarmanGrewal\192.168.2.15:String) [Get-Content], ArgumentException
+ FullyQualifiedErrorId : ItemExistsArgumentError,Microsoft.PowerShell.Commands.GetContentCommand
Get-Content : Cannot find path 'C:\Users\HarmanGrewal\192.168.2.15' because it does not exist.
At C:\Users\HarmanGrewal\Google Drive\win213\assignment2\assignment2QuestionAnswer1.ps1:13 char:1
+ Get-Content $array1 | export-csv -path "C:\Users\HarmanGrewal\test.tx …
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Users\HarmanGrewal\192.168.2.15:String) [Get-Content], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetContentCommand
}, { " ID":8, "名称":"饮料&#34 ;, "蛞蝓":"饮&#34 ;, "子":[ { " ID":9, "名称":"苏打&#34 ;, "蛞蝓":"苏打&#34 ;, "子":[ { " ID":10, " name":" Milk Sake", "蛞蝓":"乳起见&#34 ;, "子":[ { " ID":12, "名称":"芒果汁", "蛞蝓":"芒果果汁&#34 ;, "子":[
],
"parent_id":2
},
{
"id":4,
"name":"Banana Cake",
"slug":"banana-cake",
"child":[
],
"parent_id":2
}
],
"parent_id":1
},
{
"id":5,
"name":"Donut",
"slug":"donut",
"child":[
{
"id":6,
"name":"Hony Donut",
"slug":"hony-donut",
"child":[
{
"id":7,
"name":"Black Hony Donut",
"slug":"black-hony-donut",
"child":[
],
"parent_id":6
}
],
"parent_id":5
}
],
"parent_id":1
}
],
"parent_id":0
} ]
这是dinamic,可以为此提供帮助
答案 0 :(得分:0)
您的Json数据似乎没有正确格式化,但如果它很好,那么您可以将您的Json数据从Controller发送到View,如下所示:
return view('your-view')->with('json', $json);
或
return view('your-view', ['json'=>$json]);
或
return View::make('your-view')->with('json', $json);
然后在您的刀片文件中,您需要使用foreach来获取如下所示的所有数据:
@foreach($json as $data)
{{ $data->item }}
@endforeach
您还可以将Json数据转换为数组,然后发送如下:
$array =json_decode( json_encode($json), true);
return view('your-view')->with('array', $array);
然后在您的刀片文件中,您需要使用foreach来获取如下所示的所有数据:
@foreach($array as $data)
{{ $data['item'] }}
@endforeach