I have saved a list of JSON files stored in a local folder. What I've been trying to do is to view all those JSON files to a listbox then auto populate the JSON file selected in a series of textfields for each attribute.
Here are the contents of each JSON FILES and they are saved in a specific folder inside the jsonlibrary where the project is saved.
{ "FirstName": "Allen", "LastName": "Lex", "Email": "allen.lex", "TeamName": "Allen Lex", "Password": "allen123", "IsActive": "Yes", "UserId": 15 }
{ "FirstName": "Eddie", "LastName": "Chavo", "Email": "eddie.chavo", "TeamName": "Eddie Chavo", "Password": "eddie123", "IsActive": "Yes", "UserId": 120 }
I'm kinda new to c# and JSON files at the same time. Anyone can help me with this? Thanks a lot!
What I have tried:
Here's also my code in adding/creating a JSON file and save it to the folder:
string isActive = chkIsActive.Checked ? "Yes" : "No";
var account = new UserAccount()
{
FirstName = txtFirstName.Text,
LastName = txtLastName.Text,
Email = txtEmail.Text,
TeamName = txtTeamName.Text,
Password = txtPassword.Text,
IsActive = isActive,
UserId = int.Parse(txtUserId.Text)
};
string jsonFilePath = $@"{Environment.CurrentDirectory}\Output\" + txtFirstName.Text + " " + txtLastName.Text + ".json";
JsonMgr.SerializeObj_ToFile<UserAccount>(account, jsonFilePath);
MessageBox(.)Show("Successfully added new record", "Added user", MessageBoxButtons.OK, MessageBoxIcon.Information);