Click or drag to resize
Json.NET

Deserialize a Dictionary

 

This sample deserializes JSON into a dictionary.

Sample
Usage
string json = @"{
  'href': '/account/login.aspx',
  'target': '_blank'
}";

Dictionary<string, string> htmlAttributes = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

Console.WriteLine(htmlAttributes["href"]);
// /account/login.aspx

Console.WriteLine(htmlAttributes["target"]);
// _blank