jc is a JSONItem
j(0) - j(2) Are children of jc
They are not JSONItems but values of jc (similar to a dictionary)
Tough to wrap your head around at times.
Try this:
[code] dim j as new JSONItem
j.value(“AAA”) = “Alpha”
j.value(“BBB”) = “Bravo”
j.value(“CCC”) = “Charlie”
dim jc as JSONItem
dim i as integer
Dim myValues() As String = j.Names
for i = 0 to myValues.Ubound // 0 to 2jc.Append = j.child(i) // OutOfBoundsException !!
MsgBox myValues(i) + " value is " + j.Value(myValues(i)).StringValue
next[/code]
You either store your “values” for each JSONItem as children (dictionary) or as arrays
You then look them up using either the dictionary methodology (hasName, lookup, etc) or the array methodology (append, insert, etc)
The Language reference on JSON.Child is confusing. There are four versions. Two apply to array children and two to dictionary children
These apply to Array Children
JSONItem.Child ( Index As Integer ) As JSONItem
Returns a child with the passed index. Index is zero-based. < - ONLY if it is an array child
MethodJSONItem.Child ( Index As Integer, Assigns obj As JSONItem )
Sets a child to a JSONItem by index. Index is zero-based.
These apply to Dictionary Children
MethodJSONItem.Child ( Name As String ) As JSONItem
Returns a child with the passed name.
MethodJSONItem.Child ( Name As String, Assigns obj As JSONItem )
Sets a named child to a JSONItem.