using Newtonsoft.Json; // create object from JSON string string jsonData = "{ 'name': 'John', 'age': 30 }"; Person person = JsonConvert.DeserializeObject(jsonData); // Person class representation public class Person { public string Name { get; set; } public int Age { get; set; } }
using System.Text.Json; // create object from JSON string string jsonData = "{ 'name': 'John', 'age': 30 }"; Person person = JsonSerializer.DeserializeIn both examples, the IJsonSerializer interface is used to deserialize JSON data into objects. The first example uses the Newtonsoft.Json library while the second example uses System.Text.Json library.(jsonData); // Person class representation public class Person { public string Name { get; set; } public int Age { get; set; } }