当然使用LitJson前当然要有LitJson才行!
LitJson.dll下载:https://pan.baidu.com/s/1USWw9SETaxa62QTEU1eXWA 密码: bnyu
LitJson官方GitHub:https://github.com/LitJSON/litjson
然后我们需要两个保存数据的类:
public class Band //一个乐队类
{
public string Name; //乐队名
public int Number; //人数
public Member[] Member; //成员
public Band() //一个空的构造函数
{
}
public Band(string name, int number, Member[] member) //一个带参构造函数
{
Name = name;
Number = number;
Member = member;
}
}
//
public class Member //一个成员信息类
{
public string Name; //成员名称
public int Age; //成员名称
public Member() //空的构造函数
{
}
public Member(string name, int age) 带参的构造函数
{
Name = name;
Age = age;
}
}
创建Json文件:
方法一