1 回答

TA貢獻1795條經(jīng)驗 獲得超7個贊
你錯過了一些小的關(guān)鍵點
$knxGenSet = (object) [
'general' => (object) ["language" => $_POST["langsetts"],
"workingmode" => $_POST["wmodesetts"]
]
];
for($j=0; $j<2; $j++) {
$scene = (object) [
'id' => $j,
'calendar_event' => $_POST["calendarevent" . $j]
];
for($ii=0; $ii<2; $ii++) {
$scene->element[] = (object) [
"device" => "boiler".$ii,
"active_state"=> "on",
"hybernation_state"=> "off",
"calendar_name"=> "roomlink4"
];
}
$knxGenSet->scene[] = $scene;
}
print json_encode($knxGenSet);
輸出
{
"general": {
"language": null,
"workingmode": null
},
"scene": [{
"id": 0,
"calendar_event": null,
"element": [{
"device": "boiler0",
"active_state": "on",
"hybernation_state": "off",
"calendar_name": "roomlink4"
}, {
"device": "boiler1",
"active_state": "on",
"hybernation_state": "off",
"calendar_name": "roomlink4"
}]
}, {
"id": 1,
"calendar_event": null,
"element": [{
"device": "boiler0",
"active_state": "on",
"hybernation_state": "off",
"calendar_name": "roomlink4"
}, {
"device": "boiler1",
"active_state": "on",
"hybernation_state": "off",
"calendar_name": "roomlink4"
}]
}]
}
- 1 回答
- 0 關(guān)注
- 93 瀏覽
添加回答
舉報