- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
 
- 纳金币
- 53520
- 精华
- 316
|
来自:博客 - 947633658
Json的序列化似乎是一个老生长谈的问题,今天小弟有幸被Json宠幸,特地发此贴谈下感受; string 感受=“不得不说json真是好用,用一遍还想用第二遍”
下面分享下小弟的json序列化方法
public class JsonInt
{
public string TwoKeyTojson(string modle,string ins)
{
TwoKey twoKey = new TwoKey();
//序列化赋值
twoKey.Modle = modle;
twoKey.Ins = ins;
//神奇的转换
string json = JsonUtility.ToJson(twoKey);
return json;
}
public class TwoKey
{
//一号索引
public string Modle;
//二号索引
public string Ins;
public override string ToString()
{
return string.Format(Modle+":{0},"+Ins+":{1}",Modle,Ins);
}
}
}
代码的蜜汁命名还请见谅,个人把Json看作是一个由不同索引以及相对应内容组成的模块化数据格式
此次小弟用的是Unity提供的序列化方法
|
|