Unity3D 用LitJson读取Json文件
1、先下载LitJson库文件放入Unity3D/Assets/Plugins里面 如果没有请自行创建
2、注意如果有中文保存的格式需要是UTF-8否则会出现乱码
下面展示一些 内联代码片
。
// 读取Json文件
string filePath = Application.dataPath + "/Resources/Json/test 1.json";
string jsonStv= File.ReadAllText(filePath);
JsonData json = JsonMapper.ToObject(jsonStv);
Debug.Log(json["itemID"].ToJson());
Debug.Log(json["name"].ToJson());
Debug.Log(json["type"].ToJson());
Debug.Log(json["Effect"].ToJson());
Debug.Log(json["describe"].ToJson());
解析成功
测试脚本及库文件下载地址
https://download.csdn.net/download/weixin_47428955/16683570