My program has a class with many properties that store all the settings and information for a user’s project, like this:
Class Config{
public bool EnableYoutube { get; set; }= true;
public bool EnableFacebook { get; set; }= true;
}
When the user saves, I serialize this class to JSON and save it to a text file. Conversely, when the user loads a project, I read the text file and deserialize the JSON to restore the project’s settings and information.
Now I have a tricky problem: when I update the software, I may add some features and need to modify or add new properties to this class, like this:
Class Config{
public bool EnableYoutube { get; set; }= true;
public bool EnableTiktok { get; set; }= true;
}
When the user updates the software and then loads a project, the deserialization of this JSON fails because the structure of the two classes has changed.
I may use a database later, but now the project schedule is tight and I can’t make too big a switch. Maybe there are better ways to save settings in a plain text file? How can I solve this problem?