I am trying to deserialize my JSON file in C# and getting error below: "An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code"
My JSON is:
[{"Yes":"52","No":"41"}]
My c# code is
public class survey
{
public string Yes { get; set; }
public string No { get; set; }
}
protected void Button1_Click(object sender, EventArgs e)
{
using (StreamReader r = new StreamReader("sample.json"))
{
string json = r.ReadToEnd();
var items = JsonConvert.DeserializeObject<survey>(json);
var a = items.Yes;
TextBox1.Text = a;
}
}
Can any one please help me.
