You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
on previous versions of ESPEASY, for example ESPEasy_v2.0.0-dev11, there was no "OK" word at the end of the JSON. This word bothers me because in php JSON_DECODE can no longer function correctly because of the word.
Normally, a json remains a json. The "OK" has nothing to do here it comes out of the object it's dirty.
otherwise I have to do a str_replace "OK" by "" it's not clean...
can you tell me why "OK" is here? How do I get my PHP code to work ? My code is
Hello, since the ESPEASY MEGA version, when you check the status of a GPIO, a JSON appears like this : /control?cmd=Status,GPIO,12
{
"log": "",
"plugin": 1,
"pin": 12,
"mode": "output",
"state": 0
}
Ok
on previous versions of ESPEASY, for example ESPEasy_v2.0.0-dev11, there was no "OK" word at the end of the JSON. This word bothers me because in php JSON_DECODE can no longer function correctly because of the word.
Normally, a json remains a json. The "OK" has nothing to do here it comes out of the object it's dirty.
otherwise I have to do a str_replace "OK" by "" it's not clean...
can you tell me why "OK" is here? How do I get my PHP code to work ? My code is
$json = file_get_contents("http://mysonoff/control?cmd=Status,GPIO,12");
$array = json_decode($json, true);
if ($array["state"] === 0) {
echo "OMG my sonoff is OFF";
} else {
echo 'OH YES my sonoff is ON';
fclose;
}
Thanks x)
The text was updated successfully, but these errors were encountered: