diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index d089454..a5aa202 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -24,18 +24,18 @@ namespace CryptoCalc public partial class MainWindow : Window { private readonly Random rand = new(); + private readonly JsonSerializerOptions jsonOptions = new(); public MainWindow() { InitializeComponent(); - + jsonOptions.WriteIndented = true; } private void saveButton_Click(object sender, RoutedEventArgs e) { Debug.WriteLine("asdf"); - var weatherForecast = new WeatherForecast { Date = DateTime.Parse("2019-08-01"), @@ -45,7 +45,7 @@ namespace CryptoCalc }; string fileName = "asdf.json"; - string jsonString = JsonSerializer.Serialize(weatherForecast); + string jsonString = JsonSerializer.Serialize(weatherForecast, jsonOptions); File.AppendAllText(fileName, jsonString); Debug.WriteLine(File.ReadAllText(fileName));