Back to course

Working with JSON: Serialization

C# Zero to Hero: Comprehensive Programming Masterclass

JSON Serialization

Most modern apps communicate using JSON. In C#, we use System.Text.Json.

Convert Object to JSON

csharp var user = new User { Name = "Alice", Age = 25 }; string jsonString = JsonSerializer.Serialize(user);

Convert JSON to Object

csharp User user = JsonSerializer.Deserialize(jsonString);