Writing indented
This commit is contained in:
parent
755ffa610f
commit
717dfdbb36
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue