I have string json as
"[{\"Key\":\"a\",\"Value\":\"1\"},{\"Key\":\"b\",\"Value\":\"2\"}}]"
I want parse to object
class abc{
public string a{get; set;}
public string b{get; set;}
}
Please, help me
I have string json as
"[{\"Key\":\"a\",\"Value\":\"1\"},{\"Key\":\"b\",\"Value\":\"2\"}}]"
I want parse to object
class abc{
public string a{get; set;}
public string b{get; set;}
}
Please, help me
you have to Newtonsoft Library and use
var dict= JsonConvert.DeserializeObject<Dictionary<string,int>>("[{\"Key\":\"a\",\"Value\":\"1\"},{\"Key\":\"b\",\"Value\":\"2\"}}]");
Json.NET is a Popular high-performance JSON framework for .NET
Install this nuget package then it's as simple as:
var json = "[{\"Key\":\"a\",\"Value\":\"1\"},{\"Key\":\"b\",\"Value\":\"2\"}}]";
var items = JsonConvert.DeserializeObject<List<abc>>(json);
I don't know about parsing to a defined object.
However you can use A .Net library called Newtonsoft
JObject o = JObject.Parse(x.ToString());
With JObject being an instance of Newtonsoft.JSON.Linq.JObject