Back to course

Working with JSON in .NET

.NET Zero to Hero: Master C# and Modern App Development

Serialization and Deserialization

JSON is the standard for web data. Use System.Text.Json to convert objects to JSON and vice versa.

Serialize (Object to String):

csharp var user = new User { Name = "Ali" }; string json = JsonSerializer.Serialize(user);

Deserialize (String to Object):

csharp var userObj = JsonSerializer.Deserialize(json);