title: JSON Config Handler in C# with simple key-value update mechanism
body: <p>I'm trying to simplify my json config file handler. I want to 'expose' the properties defined in the configuration class. I can load propierties like: </p>
  
  <pre><code>string s = (ConfigurationHandler.Load(path).SomeStringValue);
  </code></pre>
  
  <p>now i want to achieve a similar behavior like commented in the code. </p>
  
  <pre><code>using Newtonsoft.Json;
  using System.IO;
  namespace JsonConfigHandler
  {
      class Program
      {
          static void Main(string[] args)
          {
              Configuration configuration = new Configuration { SomeBoolValue = true, SomeIntValue = 100, SomeStringValue = "Hello" };
              string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
              ConfigurationHandler.Save(configuration, $@"{path}\config.json");
              // now i only want to update one configuration element like SomeStringValue and then save it - how can i simplify this?
              // in this sample i do already have the Configuration loaded. But in a complex solution, whenever i quickly want to update one/multiple settings
              // i always have to load the configuraiton first, update the loaded configuration.key/element, set the value for the key/element, save it again. 
              // how can i 'expose' these setting-elements/keys to easily update them in one line of code like:
              // ConfigurationHandler.UpdateConfigSetting("Key", "Value");
              configuration.SomeStringValue = "Goodbye";
              ConfigurationHandler.Save(configuration, $@"{path}\config.json");
          }
      }
      public static class ConfigurationHandler
      {
          public static Configuration Load(string path)
          {
              return JsonConvert.DeserializeObject&lt;Configuration&gt;(File.ReadAllText(path));
          }
          public static void Save(Configuration conf, string path)
          {
              using (StreamWriter streamWriter = new StreamWriter(path))
              {
                  streamWriter.Write(JsonConvert.SerializeObject(conf, Formatting.Indented));
              }
          }
      }
      public class Configuration 
      {
          public string SomeStringValue { get; set; }
          public int SomeIntValue { get; set; }
          public bool SomeBoolValue { get; set; }
      }
  }
  </code></pre>