Skip to content

Latest commit

 

History

History
19 lines (14 loc) · 440 Bytes

serialize-and-deserialize.md

File metadata and controls

19 lines (14 loc) · 440 Bytes

Serializatioin and Deserialization with System.Text.Json

Serialization

// simple
var jsonString = JsonSerializer.Serialize(weatherForecast);

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

Deserialization

// simple
var weatherForecast = JsonSerializer.Deserialize<WeatherForecast>(jsonString);