JSON序列化到文件与反序列化到文件
发布时间
阅读量:
阅读量
一、序列化成一个文件
- 将JSON格式的数据保存为一个文件,该文件可通过记事本程序进行查看。首先需要构造一个Movie类的实例对象。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JSONDemo
{
public class Movie
{
public string Name { get; set; }
public string Director { get; set; }
public int ReleaseYear { get; set; }
}
}
- 创建movie对象的实例,并为该对象的相关属性进行赋值操作,随后将其转换为文件形式进行存储。实现方式共包含两种,具体源代码如下:
using System;
using System.Collections.Generic;
using System.L
全部评论 (0)
还没有任何评论哟~
