var serializedArray = new JavaScriptSerializer().Deserialize<object[]>(filter);
The content of the variable filter
is [["Title","contains","foo"],"and",["Name","contains","foo"]]
.
Content of serializedArray
is "object[3]","and","object[3]"
.
Content of serializedArray[0]
is object[3]
which are "Title", "contains", "foo"
.
serializedArray
can be used with index operator, and foreach
is applicable. But not for serializedArray[0]
.
Funny enough, both the serializedArray
and serializedArray[0]
have the type of Object[].
What's the way to grab the value "Title" or "Name"?
var serializedArray = new JavaScriptSerializer().Deserialize<object[]>(filter);
foreach (var item in serializedArray)
{
if (item is string)
{
var element = item;
}
else
foreach (var innerItem in (object[])item)
{
var element = innerItem;
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments