I have a JSON file which looks like this
{
"Response": {
"Part": {
"Name": "Part1",
"Rev": "01",
"Title": "Part1",
"current": "Released",
"Part": [
{
"Name": "Part2",
"Rev": "00",
"Title": "Part2",
"current": "Released",
"Part": {
"Name": "Part3",
"Rev": "R00",
"Title": "Part3",
"current": "Released"
}
},
{
"Name": "Part4",
"Rev": "00",
"Title": "Part4",
"current": "Released"
}
]
}
}
}
I have created my class objects as this
public class PartObj
{
public string Name { get; set; }
public string Rev { get; set; }
public string Title { get; set; }
public string current { get; set; }
public List<PartObj> Part { get; set; }
}
public class Response
{
public PartObj Part { get; set; }
}
public class Root
{
public Response Response { get; set; }
}
But I am unable to deserialize the JSON string
Root items = JsonConvert.DeserializeObject<Root>(jsonStr);
The error says
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.List`1[PartObj ]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
Any Solution for Deserializing this?