// simple
var jsonString = JsonSerializer.Serialize(weatherForecast);
// with options
var options = new JsonSerializerOptions { WriteIndented = true };
var jsonString = JsonSerializer.Serialize(weatherForecast, options);
// simple
var weatherForecast = JsonSerializer.Deserialize<WeatherForecast>(jsonString);