JSON with System.Text.Json
JsonSerializer converts objects to JSON and back.
Example
using System.Text.Json;
var json = JsonSerializer.Serialize(new Person("Ada", 30));
Console.WriteLine(json);
var p = JsonSerializer.Deserialize<Person>(json);
Console.WriteLine(p!.Name);
record Person(string Name, int Age);Exercise
To JSON.
JsonSerializer.(obj)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.