I have the following string:
[
[
"costCenterRefNavigation.title",
"contains",
"hospital"
],
"and",
[
"workCenterRefNavigation.workCenterTitle",
"contains",
"electrical"
],
"and",
[
"scheduleType",
"contains",
"monthly"
]
]
I want to deserialize this string into Objects. I tried to created some classes as following:
class GridFilterModel
{
public List<GridFilterElementModel> FilterItem { get; set; }
}
class GridFilterElementModel
{
public string ColumnName { get; set; }
public string Operand { get; set; }
public string Value { get; set; }
}
Then, I tried to deserialize the string using the following code:
var filterElements = JsonConvert.DeserializeObject<GridFilterModel>(filter);
But there is a runtime error says:
Cannot deserialize the current JSON array, because the type requires a
JSON object (e.g. {“name”:”value”}) to deserialize correctly. To fix
this error either change the JSON to a JSON object (e.g.
{“name”:”value”}) or change the deserialized type to an array or a
type that implements a collection interface.
How can I fix this?