1.首先创建一个实例对象City,并声明构造函数.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JSONDemo
{
public class City
{
public string Country { get; set; }
public IList<string> Name { get; set; }
public City()
{
this.Name = new List<string>
{
"Auckland",
"Wellington",
"Hamilton"
};
}
}
}
2.JSON反序列化数据
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using GongHuiNewtonsoft.Json;
namespace JSONDemo
{
class Program
{
static void Main(string[] args)
{
string json = @"{
'Country':'New Zealand',