0
次のJSONオブジェクトを抽出する方法はわかりません。私はforeachを使用しようとしますが、動作しません。私たちを手伝ってくれますか? ここでJSONファイル:実際にはPHPを使用したJSON複合ツリー
{
"success":true,
"moreDataAvailable":true,
"ewons":
[
{
"id":252459,
"name":
"eWON_TEST",
"tags":
[
{
"id":107060,
"name":"TEMP_EXT",
"dataType":"Int",
"description":"Température extérieure",
"alarmHint":"",
"value":15.0,
"quality":"good",
"ewonTagId":1,
"history":
[
{
"date":"2016-05-09T16:06:49Z",
"quality":"initialGood",
"value":64.0
},
{
"date":"2016-05-09T16:16:49Z",
"quality":"initialGood",
"value":6.0
},
{
"date":"2016-05-09T16:21:49Z",
"quality":"initialGood",
"value":6.0
}
]
},
{
"id":107072,
"name":"TEMP_IN",
"dataType":"Int",
"description":"Température intérieure",
"alarmHint":"",
"value":22.0,
"quality":"good",
"ewonTagId":5,
"history":
[
{
"date":"2016-05-09T17:01:49Z",
"quality":"initialGood",
"value":22.0
},
{
"date":"2016-05-09T17:06:49Z",
"value":22.0
},
{
"date":"2016-05-09T17:11:49Z",
"value":22.0
}
]
}
],
"lastSynchroDate":"2016-12-16T15:21:22Z"
}
]
}
、私は、各行に次の情報を各タグの履歴を表示したいと思います:
['id'],['name'],['dataType'],['descritption'],['ewonTagId'],['id(from ewons)'],['name(from ewons)'],['date'],['quality(from history)'],['value']
私はこの時点で、次のコードを持っていますが、ループのために試したものは何もありませんでした。
<?php
//Read JSON file
$filename ='fichier.json';
$json = file_get_contents($filename);
//convert json object to php associative array
$data = json_decode($json,true);
// Loop trough the array
foreach(???) {
echo ???
}
?>
私は今朝試してみましたが、私は成功しませんでした:-( –
この質問に100回も重複があります。 – RiggsFolly