Return alarm status via web dev module

The problem here is that the jsonEncode() function does not seem to accept the “list” object produced by the queryStatus() function, so the jsonString variable never points to anything other than a NoneType. We can convert this to a Python list of alarm event objects using syntax like:

alarmDict = [x for x in system.alarm.queryStatus(source=[“HiAlarm”])]

However, a list of objects like this will cause the jsonEncode function to reach max recursion depth very quickly.

I think that the easiest solution is to convert this data to a PyDataset before encoding to Json. This would look something like this:

alarmDict = system.dataset.toPyDataSet(system.alarm.queryStatus(source=[“HiAlarm”]).getDataset())
jsonString = system.util.jsonEncode(alarmDict)
return {“response”:jsonString, “contentType”:“application/json”}