mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 16:59:47 +00:00
Improved the readability of the settings.json
file by using indentation and enum names instead of numbers; fixes #53
This commit is contained in:
parent
76dd08ee11
commit
145181d9f8
@ -1,4 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Settings.DataModel;
|
||||
|
||||
@ -13,6 +15,12 @@ public sealed class SettingsManager
|
||||
{
|
||||
private const string SETTINGS_FILENAME = "settings.json";
|
||||
|
||||
private static readonly JsonSerializerOptions JSON_OPTIONS = new()
|
||||
{
|
||||
WriteIndented = true,
|
||||
Converters = { new JsonStringEnumConverter() },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The directory where the configuration files are stored.
|
||||
/// </summary>
|
||||
@ -101,7 +109,7 @@ public sealed class SettingsManager
|
||||
return;
|
||||
|
||||
var settingsJson = await File.ReadAllTextAsync(settingsPath);
|
||||
var loadedConfiguration = JsonSerializer.Deserialize<Data>(settingsJson);
|
||||
var loadedConfiguration = JsonSerializer.Deserialize<Data>(settingsJson, JSON_OPTIONS);
|
||||
if(loadedConfiguration is null)
|
||||
return;
|
||||
|
||||
@ -120,7 +128,7 @@ public sealed class SettingsManager
|
||||
if(!Directory.Exists(ConfigDirectory))
|
||||
Directory.CreateDirectory(ConfigDirectory!);
|
||||
|
||||
var settingsJson = JsonSerializer.Serialize(this.ConfigurationData);
|
||||
var settingsJson = JsonSerializer.Serialize(this.ConfigurationData, JSON_OPTIONS);
|
||||
await File.WriteAllTextAsync(settingsPath, settingsJson);
|
||||
}
|
||||
|
||||
|
2
app/MindWork AI Studio/wwwroot/changelog/v0.8.6.md
Normal file
2
app/MindWork AI Studio/wwwroot/changelog/v0.8.6.md
Normal file
@ -0,0 +1,2 @@
|
||||
# v0.8.6, build 168
|
||||
- Improved the readability of the `settings.json` file by using indentation and enum names instead of numbers
|
Loading…
Reference in New Issue
Block a user