1.首先创建一个类,含有私有的构造函数.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JSONDemo
{
public class Website
{
public string Url { get; set; }
private Website()
{ }
public Website(Website website)
{
if (website == null)
throw new ArgumentNullException("website");
this.Url = website.Url;
}
}
}
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 = @"{'Url':'http://blog.csdn.net/lovegonghui/article/details/50251873'}";