I'm trying to convert a json array of objects to a C# list, but I can't make it work. Currently, I have made this class:
public class FineModel
{
public String officer { get; internal set; }
public String target { get; internal set; }
public int amount { get; internal set; }
public String reason { get; internal set; }
public String date { get; internal set; }
public FineModel() { }
}
Now, I have this JSON that i want to deserialize, which seems to be correctly formed:
[
{
"officer":"Alessia Smith",
"target":"Scott Turner",
"amount":1800,
"reason":"test",
"date":"9/4/2017 3:32:04 AM"
}
]
And the C# line which should do the magic is:
List<FineModel> removedFines = JsonConvert.DeserializeObject<List<FineModel>>(json);
It returns one object, but when I try to print its values, it returns 0 for the amount property and empty for the strings, like if i did . What could be wrong here?
Thanks in advance!