I have a JSON file from domoticz that I want to grab the "result Data" value to get the current state of a switch. I have googled a bit to find out how to extract values from a JSON file but I cannot find out how to do it..
This is the JSON file:
{
"ActTime" : 1628108913,
"AstrTwilightEnd" : "00:00",
"AstrTwilightStart" : "00:00",
"CivTwilightEnd" : "22:13",
"CivTwilightStart" : "03:44",
"DayLength" : "16:34",
"NautTwilightEnd" : "23:58",
"NautTwilightStart" : "01:58",
"ServerTime" : "2021-08-04 22:28:33",
"SunAtSouth" : "12:58",
"Sunrise" : "04:41",
"Sunset" : "21:15",
"app_version" : "2020.2",
"result" :
[
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"CustomImage" : 0,
"Data" : "On",
"Description" : "",
"DimmerType" : "none",
"Favorite" : 1,
"HardwareID" : 1,
"HardwareName" : "RTX",
"HardwareType" : "RFXCOM - RFXtrx433 USB 433.92MHz Transceiver",
"HardwareTypeVal" : 1,
"HaveDimmer" : true,
"HaveGroupCmd" : true,
"HaveTimeout" : false,
"ID" : "20C0C0C",
"Image" : "Light",
"IsSubDevice" : false,
"LastUpdate" : "2021-08-04 22:02:53",
"Level" : 100,
"LevelInt" : 15,
"MaxDimLevel" : 15,
"Name" : "Max H\u00f6rnlampa",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" :
[
0
],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"Status" : "On", --- THIS IS THE VALUE I WANT
"StrParam1" : "",
"StrParam2" : "",
"SubType" : "Anslut",
"SwitchType" : "On/Off",
"SwitchTypeVal" : 0,
"Timers" : "true",
"Type" : "Lighting 2",
"TypeImg" : "lightbulb",
"Unit" : 2,
"Used" : 1,
"UsedByCamera" : false,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "291"
}
],
"status" : "OK",
"title" : "Devices"
}
This is what Ive come up with:
$.getJSON('http://**.*.*.**:8080/json.htm?type=devices&rid=***', function (result) {
alert(result.status);
});
But I get the value "OK" but I want on or off. Thanks beforehand!
Best regards Max