I'm currently working on an assignment where I need to update a list with data from my json file. However my List keeps coming up as null and I can't seem to find why any help would be greatly appreciated.
I have been trying to look around, but many of the issues I have looked at just mention on how to pull the data not how to resolve this issue.
My classes and code:
public class input
{
DateTime signed;
DateTime portal;
public DateTime Signed { get => signed; set => signed = value; }
public DateTime Portal { get => portal; set => portal = value; }
}
public class InputCollection
{
private List<input> inputs;
public List<input> Inputs { get => inputs; set => inputs = value; }
}
using (StreamReader streamReader = new StreamReader("C:\\Users\\Dominik\\Documents\\SenateCodingExercise\\CodingAssignment\\CodingAssignment\\input.json"))
{
//Reads all the data in the file
string json = streamReader.ReadToEnd();
//converting json string to a serious of objects
InputCollection inputCollection = JsonConvert.DeserializeObject<InputCollection>(json);
Console.WriteLine(inputCollection.Inputs.Count);
}
My JSON file looks something like this:
{
"Schmidt, Wayne": {
"signed": "Friday, June 14, 2019 @ 10:58:21 PM"
},
"Hertel, Curtis": {
"portal": "Wednesday, June 5, 2019 @ 10:30:36 AM"
},
"Daley, Kevin": {
"signed": "Tuesday, June 4, 2019 @ 4:07:17 PM"
}
}