Pulling array data from json

Hello – having a little trouble extracting the “obs” array data from this json:


I think the double square brackets may be the issue. I don’t know how to get rid of them. This json stream comes in via a UDP broadcast message from a weather station. Here is the code I’m using:

Dim jsonDict As Xojo.Core.Dictionary = Xojo.Data.ParseJSON(str(TextField1.Text).ToText)
Dim resultsArray( ) As Auto


jsonDict.Lookup("type", "---") = "obs_air" then 

Dim obs_air_pressure_v As Integer
Dim obs_air_pressure As String

Dim obs_air_temp_v As Integer
Dim obs_air_temp As String

resultsArray( ) = jsonDict.Value("obs")

obs_air_pressure_v = resultsArray(2)
obs_air_pressure = str(obs_air_pressure_v)

obs_air_temp_v =  resultsArray(3)
obs_air_temp = str(obs_air_temp_v)

TextField2.Text = obs_air_pressure
TextField3.Text = obs_air_temp



I’m doing the same for another json broadcast message from the same weather station and it works fine – note this one does not have double square brackets :


the code:


 jsonDict.Lookup("type", "---") = "rapid_wind" then 

Dim rapid_wind_speed_v As Integer
Dim rapid_wind_speed As String

Dim rapid_wind_dir_v As Integer
Dim rapid_wind_dir As String

resultsArray( ) = jsonDict.Value("ob")

rapid_wind_speed_v =  resultsArray(1)
rapid_wind_speed = str(rapid_wind_speed_v)

rapid_wind_dir_v =  resultsArray(2)
rapid_wind_dir = str(rapid_wind_dir_v)

TextField2.Text = rapid_wind_speed
TextField3.Text = rapid_wind_dir



I think with the only difference in the json structure being double brackets in one (not working) and single square brackets in the other (working) leads me to think that the extra brackets are the issue. Any Ideas to get rid of them would be a great help. Or if there is something else I’m missing.


Forgot to mention that I get an – out of bounds exception – on these lines:

obs_air_pressure_v = resultsArray(2)

obs_air_temp_v =  resultsArray(3)