I've spent many hours with this script. It executes without error, but does NOT extract the JSON data for some reason, the 2nd WriteLog statement gives an empty string. Any help appreciated.
My first post - couldn't figure out how to insert code as in other posts I've seen (sorry).
Imports System.Web.Script.Serialization
Sub Main(ByVal Parms As Object)
Try
Dim json As New JavaScriptSerializer
Dim DataRaw as String = hs.DeviceStringByName("Big5 HTTP WU")
' data:
' {"observations":[{"stationID":"KNMSILVE59","obsTimeUtc":"2019-08-07T17:45:02Z","obsTimeLocal":"2019-08-07 11:45:02","neighborhood":"Silver City","softwareType":"myAcuRite","country":"US","solarRadiat ion":null,"lon":-108.2144928,"realtimeFrequency":null,"epoch":1565199902,"lat ":32.86399078,"uv":2.0,"winddir":317,"humidity":40,"qcSt atus ":-1,"imperial":{"temp":84,"heatIndex":83,"dewpt":57,"windChi ll ":84,"windSpeed":3,"windGust":6,"pressure":30.29,"precip Rate ":0.0,"precipTotal":0.0,"elev":6864}}]}
hs.WriteLog("Parse", DataRaw)
Dim jData As Observation = json.Deserialize(Of Observation)(DataRaw)
hs.WriteLog("PARSE", jData.stationID)
Catch Ex As Exception
hs.WriteLog("Parse",Ex.Message)
End Try
End Sub
Public Class Imperial
Public Property temp As Integer
Public Property heatIndex As Integer
Public Property dewpt As Integer
Public Property windChill As Integer
Public Property windSpeed As Integer
Public Property windGust As Integer
Public Property pressure As Double
Public Property precipRate As Double
Public Property precipTotal As Double
Public Property elev As Integer
End Class
Public Class Observation
Public Property stationID As String
Public Property obsTimeUtc As String
Public Property obsTimeLocal As String
Public Property neighborhood As String
Public Property softwareType As String
Public Property country As String
Public Property solarRadiation As Object
Public Property lon As Double
Public Property realtimeFrequency As Object
Public Property epoch As Integer
Public Property lat As Double
Public Property uv As Double
Public Property winddir As Integer
Public Property humidity As Integer
Public Property qcStatus As Integer
Public Property imperial As Imperial
End Class
My first post - couldn't figure out how to insert code as in other posts I've seen (sorry).
Imports System.Web.Script.Serialization
Sub Main(ByVal Parms As Object)
Try
Dim json As New JavaScriptSerializer
Dim DataRaw as String = hs.DeviceStringByName("Big5 HTTP WU")
' data:
' {"observations":[{"stationID":"KNMSILVE59","obsTimeUtc":"2019-08-07T17:45:02Z","obsTimeLocal":"2019-08-07 11:45:02","neighborhood":"Silver City","softwareType":"myAcuRite","country":"US","solarRadiat ion":null,"lon":-108.2144928,"realtimeFrequency":null,"epoch":1565199902,"lat ":32.86399078,"uv":2.0,"winddir":317,"humidity":40,"qcSt atus ":-1,"imperial":{"temp":84,"heatIndex":83,"dewpt":57,"windChi ll ":84,"windSpeed":3,"windGust":6,"pressure":30.29,"precip Rate ":0.0,"precipTotal":0.0,"elev":6864}}]}
hs.WriteLog("Parse", DataRaw)
Dim jData As Observation = json.Deserialize(Of Observation)(DataRaw)
hs.WriteLog("PARSE", jData.stationID)
Catch Ex As Exception
hs.WriteLog("Parse",Ex.Message)
End Try
End Sub
Public Class Imperial
Public Property temp As Integer
Public Property heatIndex As Integer
Public Property dewpt As Integer
Public Property windChill As Integer
Public Property windSpeed As Integer
Public Property windGust As Integer
Public Property pressure As Double
Public Property precipRate As Double
Public Property precipTotal As Double
Public Property elev As Integer
End Class
Public Class Observation
Public Property stationID As String
Public Property obsTimeUtc As String
Public Property obsTimeLocal As String
Public Property neighborhood As String
Public Property softwareType As String
Public Property country As String
Public Property solarRadiation As Object
Public Property lon As Double
Public Property realtimeFrequency As Object
Public Property epoch As Integer
Public Property lat As Double
Public Property uv As Double
Public Property winddir As Integer
Public Property humidity As Integer
Public Property qcStatus As Integer
Public Property imperial As Imperial
End Class
Comment