Very simple helper for reading, using one single method, keys from local appsettings.json (or whatever file). Ideal also for reading connection strings. Here the code: Console.WriteLine(SFERA.Helpers.AppSettingsJSON.AppSettings.Get("key1")); Console.WriteLine(SFERA.Helpers.AppSettingsJSON.AppSettings.Get("key2", "D:\\SFERA.Helpers\\Sample\\appsettings.json")); Console.WriteLine(SFERA.Helpers.AppSettingsJSON.ConnectionStrings.Get("cn1")); Console.WriteLine(SFERA.Helpers.AppSettingsJSON.ConnectionStrings.Get("cn2", "D:\\SFERA.Helpers\\Sample\\appsettings.json")); Here the appsettings.json: { "ConnectionStrings": { "cn1": "Persist Security Info=True;Initial Catalog=mycatalog1;server=server.com;User Id=user;Password=pwd;Max Pool Size=500;", "cn2": "Persist Security Info=True;Initial Catalog=mycatalog2;server=server.com;User Id=user;Password=pwd;Max Pool Size=500;" }, "AppSettings": { "key1": "value1", "key2": "value2" }
License
—
Deps
21
Install Size
—
Vulns
✓ 0
Published
Mar 27, 2024
$ dotnet add package SFERA.Helpers.AppSettingsJSONNo README available.