ScreenShot Of Error i have a json file which contains some data and i want to parse it but every time when i want to Deserialize Object it give me this error "Unable to find a constructor. A Class should either have a default constructor, one constructor with arguments or a constructor marked with json constructor i dont know what to do because i did not work with json before it is my first time working with json. here is my json :
{
"Addition":
{
"Easy": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
"Medium":[
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
],
"Difficult": [
"New York Bulls",
"Los Angeles Kings",
"Golden State Warriros",
"Huston Rocket"
]
}
}
here is my model class
public class Addition
{
public List<string> Easy { get; set; }
public List<string> Medium { get; set; }
public List<string> Difficult { get; set; }
public Addition() { }
}
here is my function in which i am Deserialize object
private void ReadJson()
{
var assembly = typeof(WordProblemsScreen).GetTypeInfo().Assembly;
Stream stream =
assembly.GetManifestResourceStream("MathRandomizer.demo.json");
using (var reader = new System.IO.StreamReader(stream))
{
string json = reader.ReadToEnd();
JObject jObject = JObject.Parse(json);
JToken jUser = jObject["Addition"];
var addition = JsonConvert.DeserializeObject<Addition>(json);
}
}