deepak21188
Вы можете использовать Newtonsoft.NuGet-пакет в формате JSON Он содержит класс JsonConvert, который может сериализовать или де-сериализовать объекты C# в данные JSON. Код будет выглядеть следующим образом:
public class Resource
{
public string public_id { get; set; }
public string type { get; set; }
public DateTime created_at { get; set; }
public int bytes { get; set; }
public int width { get; set; }
public int height { get; set; }
}
class Program
{
static void Main(string[] args)
{
List<Resource> resources = new List<Resource>();
resources.Add(new Resource()
{
public_id = "/OrderImages/MyImg/UploadImages/",
type = "upload",
created_at = DateTime.Now,
bytes = 234,
width = 10,
height = 20
});
string json= JsonConvert.SerializeObject(resources);
Console.Write(json);
// [{"public_id":"/OrderImages/MyImg/UploadImages/","type":"upload","created_at":"2019-11-08T13:51:54.00859-05:00","bytes":234,"width":10,"height":20}]
List<Resource> parsedResources= JsonConvert.DeserializeObject<List<Resource>>(json);
}
}