반응형
using Newtonsoft.Json;
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string json = @"[{
            'name': 'John Doe',
            'age': 30,
            'isMarried': false
        },
        {
            'name': 'Jane Doe',
            'age': 25,
            'isMarried': true
        }]";

        List<Person> persons = JsonConvert.DeserializeObject<List<Person>>(json);

        foreach (Person person in persons)
        {
            Console.WriteLine($"Name: {person.Name}, Age: {person.Age}, Married: {person.IsMarried}");
        }
    }
}

class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
    public bool IsMarried { get; set; }
}
반응형

+ Recent posts