1.首先声明一个对象Account
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JSONDemo
{
public class Account
{
public string Email { get; set; }
public bool Active { get; set; }
public DateTime CreateDate { get; set; }
public IList<string> Roles { get; set; }
}
}
2.实例化Account并给其属性赋值,然后填充其新的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)
{
Account account = new Account
{
Email = "359194966@163.com",
Active = true,
CreateDate = new DateTime(2015, 12, 10, 0, 0, 0, DateTimeK