I am \trying to parse a JSON Item whose ToString property is
The debugger reveals IsArray is True and HasName(“Item”) is false and this code fails with a TypeMismatchException
dim rec as new JSONItem
rec = fileData.Child(j)
dim aArray As Boolean = rec.IsArray
dim aName As Boolean = rec.HasName("Item")
try
dim aVal As String = rec.Value(1)
Catch e as RuntimeException
dim t As Introspection.TypeInfo = Introspection.GetType(e)
break
end try
fileData is a JSONItem with several records in it consisting of Item and ItenVal.[quote][[{“Item”:“FacCode”},{“ItemVal”:“109150016”}],[{“Item”:“LastSync”},{“ItemVal”:“2020-01-06 17:40:22”}]][/quote]
The TypeMismatchException is because an object item returns a JSONItem, not a String. You should absolutely not be using a catch all exceptions here. Catch JSONException.
Tey
dim rec as new JSONItem
Dim item as jsonitem
rec = fileData.Child(j)
dim aArray As Boolean = rec.IsArray
Item = rec.valueat(0) // first array item
dim aName As Boolean = item.HasName("Item") // should be true
// dim aVal As String = rec.Value(1)
Catch e as RuntimeException
dim t As Introspection.TypeInfo = Introspection.GetType(e)
break
end try