Because you are trying to make the library do something that it is not intended to do; it is illegal and not safe to convert the values from the type specified, array, to the type that you require, object.
In almost every language, an array is a collection of elements of the same type. Even in the JavaScript realm, you would create an array and put in the same objects in the container and then you serialize the array, pass it over to another computer over the network, or leave it there as an evidence to future alien race, once the data is to be read from string to an object, you need to make sure you are parsing the object to the correct representation. In JavaScript, you can easily tell whether string data is an array or an object representation, the first character being
[
means an array, and
{
meaning an object. Otherwise they are
mostly invalid.
But here comes the problem. You are trying to now read the data that is array, but you are trying to parse it as an object. You are telling the library to parse an object, and are providing it with data that is for an array.
To fix it, just pass the list interface as the type parameter, maybe this,
Dim data As List(Of LocIQRoot) = JsonConvert.DeserializeObject(Of List(Of LocIQRoot))(result)
This will parse the data as a List, and you can then read the objects in a quick
foreach
loop.
Also, I wrote an article on this topic that you can check out,
From zero to hero in JSON with C#[
^]. I explores some cases and scenarios, and you can find some more tips and hints in the QA section under the article.