c# 接口访回json

using System;
using Newtonsoft.Json;
interface IPerson {
string Name { get; set; }
string Email { get; set; }
}
class Person : IPerson {
public string Name { get; set; }
public string Email { get; set; }
}
class Program {
static void Main(string[] args) {
string json = "{\"Name\": \"张三\", \"Email\": \"[email protected]\"}";
IPerson person = JsonConvert.DeserializeObject(json);
Console.WriteLine(person.Name);   // 打印结果为:张三
}
}

你可能感兴趣的:(c#,开发语言)