Writing indented
This commit is contained in:
parent
755ffa610f
commit
717dfdbb36
|
@ -24,18 +24,18 @@ namespace CryptoCalc
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
private readonly Random rand = new();
|
private readonly Random rand = new();
|
||||||
|
private readonly JsonSerializerOptions jsonOptions = new();
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
jsonOptions.WriteIndented = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveButton_Click(object sender, RoutedEventArgs e)
|
private void saveButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("asdf");
|
Debug.WriteLine("asdf");
|
||||||
|
|
||||||
|
|
||||||
var weatherForecast = new WeatherForecast
|
var weatherForecast = new WeatherForecast
|
||||||
{
|
{
|
||||||
Date = DateTime.Parse("2019-08-01"),
|
Date = DateTime.Parse("2019-08-01"),
|
||||||
|
@ -45,7 +45,7 @@ namespace CryptoCalc
|
||||||
};
|
};
|
||||||
|
|
||||||
string fileName = "asdf.json";
|
string fileName = "asdf.json";
|
||||||
string jsonString = JsonSerializer.Serialize(weatherForecast);
|
string jsonString = JsonSerializer.Serialize(weatherForecast, jsonOptions);
|
||||||
File.AppendAllText(fileName, jsonString);
|
File.AppendAllText(fileName, jsonString);
|
||||||
|
|
||||||
Debug.WriteLine(File.ReadAllText(fileName));
|
Debug.WriteLine(File.ReadAllText(fileName));
|
||||||
|
|
Loading…
Reference in New Issue