Writing indented

This commit is contained in:
Stedd 2021-08-01 12:42:03 +02:00
parent 755ffa610f
commit 717dfdbb36
1 changed files with 3 additions and 3 deletions

View File

@ -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));