When you remove the Lines: in your JSON then your Code works with:
[
{
"index": 0,
"nb": "9822",
"size": 2,
Var Lines() As Variant = ParseJSON(TextArea1.Text)
For Each Line as Dictionary in Lines
If Line.HasKey("index") Then
TextArea1.AddText(EndOfLine + "index: " + Str(Line.Value("index")))
End If
Next
Var JSON As Dictionary = ParseJSON(TextArea1.Text)
Var Lines() As Variant = JSON.Value("Lines")
For Each Line As Dictionary in Lines
TextArea1.AddText(EndOfLine + "index: " + Str(Line.Value("index")))
TextArea1.AddText(EndOfLine + "size: " + Str(Line.Value("size")))
Next
Is there a reason you’re not using the JSONItem class? It’s the same engine under the hood and handles these idiosyncrasies for you.
Var js as new JSONItem(jsonString)
If not js.IsArray then
// bad format
Return
End if
Var c as integer = js.count
For i as integer = 0 to c-1
Var item as JSONItem = js.itemAt(i)
Var name = item.Value("name")
Next i