I have a json file that looks like this:
{
"id": 1,
"FirstName": "jen",
"LastName": "may",
"UserName": "jenmay",
"Password": "august",
"securityQ1": "leeds",
"securityQ2": "smith"
}{
"id": 2,
"FirstName": "lucy",
"LastName": "reed",
"UserName": "lucyreed1",
"Password": "bucket",
"securityQ1": "manchester",
"securityQ2": "bow"
}
I want to read the file to check that a username and password match a users input. I have the input as uname and pword.
I first attempt to deserialize the JSON.
public List<User> DeserializedUsersList(string json)
{
List<User> user = JsonConvert.DeserializeObject<List<User>>(json);
return user;
}
it keeps throwing me a 'Newtonsoft.Json.JsonSerializationException' exception.
I'm really new to C# and I'm not sure how to find username in the file. Then check that password matches the inputted password. How should I go about this?
Thank you!