Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3673

Expected String() but got Variant()

$
0
0

Good afternoon (o;

I have a JSON backend where I get visit status from our online shop system.
As a test I have set up a simple DesktopListBox with four columns.

So when the JSON is returned and HTTP status is 200 then I process it like:

Var jsonDict As Dictionary = ParseJSON(s)
Var visits() As Variant = jsonDict.Value("data")

TextArea1.AddText("Dict count: " + Str(visits.Count) + EndOfLine)

For Each visit As Dictionary In visits
  Var columns() As String = Array(visit.Value("Zeit"), visit.Value("ID"), visit.Value("Artikel"), visit.Value("Preis"))
  ListBox1.AddRow(columns)
Next

Now what is odd that the last visit.Value in building the String() throws this exception.
But as soon I replace it with a static String like:

Var columns() As String = Array(visit.Value("Zeit"), visit.Value("ID"), visit.Value("Artikel"), "")

It works…

Tried then with building a String array of size five like:

Var columns() As String = Array(visit.Value("Zeit"), visit.Value("ID"), visit.Value("Artikel"), visit.Value("Preis"), "")

And this works fine as well, though the last column isn’t used in the DesktopListBox.

15 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 3673

Trending Articles