Reputation: 1435
I have developed service which returns JSON data as below
{"names":["Name1","Name2","Name3","Name4"],"validname":false}
Now i want to deserialize it in c#.
I have tried with below methods, but still getting error
Dictionary<string, string[]> lst = JsonConvert.DeserializeObject<Dictionary<string, string[]>>(result);
Can anyone please help me
Upvotes: 0
Views: 83
Reputation: 514
class SomeClass
{
public string[] Names { get; set; }
public bool Validname { get; set; }
}
and then
var items = JsonConvert.DeserializeObject<SomeClass>(result);
also you can use JsonProperty attribute to map properties to json like so
[JsonProperty("names")]
public string[] MyPropertyNamedSomethingDifferent { get; set; }
Upvotes: 1