I have JSON data that I am trying to load into a dictionary but I am having a Nil exception error.
I created a Property for the application called locations_dict as Xojo.Core.Dictionary.
The JSON data has an array within it called “exam_rooms” which I am trying to load into this dictionary. The array “exam_rooms” has two elements I want called “index” and “name”.
Everything seems to go smoothly until I try to add the items to a dictionary.
[code] Dim js As New JSONItem(s)
Dim results As JSONItem = js.Value(“results”)
If results.IsArray Then
For i As Integer=0 To results.Count-1
Dim item As JSONItem = results(i)
Dim exam_rooms as JSONItem = item.Value("exam_rooms")
If exam_rooms.IsArray Then
For j As Integer=0 To exam_rooms.Count-1
Dim item1 as JSONItem = exam_rooms(j)
locations_dict.Value(item1.Value("index")) = item1.Value("name") //ERROR OCCURS HERE
Next
End If
Exit
Next
End If[/code]
The debugger shows locations_dict as Nil.
I tried entering the line:
Dim locations_dict as Xojo.Core.Dictionary
but that didn’t help.
I also tried Xojo.Data.ParseJSON but couldn’t get it to work.