一、使用Linq序列化
1.先创建一个Post对象
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JSONDemo
{
public class Post
{
public string Title { get; set; }
public string Description { get; set; }
public string Link { get; set; }
public IList<string> Categories { get; set; }
public DateTime? PostedDate { get; set; }
public string Html { get; set; }
}
}
2.再把Post置于列表中,然后实例化此对象。再实例化一个JArray对象,使用Linq把查询到的数据赋值到此对象中。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Web;
using GongHuiNewtonsoft.Json.Linq;
namespace JSONDemo
{
class Program
{
static void Main(string[] args)
{
IList<Post> list = new List<Post>