【Json】关于LitJson和相关Json的使用
来源:互联网 发布:国泰安数据库行业代码 编辑:程序博客网 时间:2024/04/27 13:42
博主在项目当中 使用litjson 来解析简单的配置表 结果发现 在移动端 litJson 并不是好用 所以简单介绍一些litjson 和在移动端用什么Json
// myDataAll = JsonMapper.ToObject<MyData[]>((File.ReadAllText(myPth)));
首先博主的用文件读取.txt 的文件 然后JsonMapper获取 myDataAll是一个类的对象
[System.Serializable] public class MyData : MonoBehaviour { public string Image { get; set; } public string Name { get; set; } public string Date { get; set; } public string Url { get; set; } public string Note { get; set; } }
[ { "Image": "icon_1.jpg", "Name": "我们正少年", "Date": "2016/6/1", "Url": "http://btv.btime.com/btvkkse/20160601/v741838.shtml", "Note": "古代走路的规矩有什么,室内的礼仪知多少,十四种失礼的吃相有谁中枪。本期穿越大讲堂为大家介绍了古代吃行等日常生活需要注意的仪态。" }, { "Image": "icon_2.jpg", "Name": "乾隆微服私访下江南", "Date": "2016/6/29", "Url": "http://btv.btime.com/btvkkse/20160707/v931181.shtml", "Note": "乾隆下江南,奇葩饭馆趣事多。吃货玩儿游戏,过关斩将困难多。本期穿越大讲堂为大家介绍了乾隆下江南时流传下来的膳食单。" }, { "Image": "icon_3.jpg", "Name": "英宗的烦恼", "Date": "2016/7/6", "Url": "http://btv.btime.com/btvkkse/20160707/v931172.shtml", "Note": "穿越明朝化身一代女医,同行相争,谁的医术更高一筹,神奇药膳引发两队的重重猜忌。本期穿越大讲堂为大家介绍了明朝名医谈允贤、李时珍等。" }, { "Image": "icon_4.jpg", "Name": "彩衣娱亲", "Date": "2016/7/13", "Url": "http://btv.btime.com/btvkkse/20160717/v980412.shtml", "Note": "两位少年为父母管教而烦恼,穿越到了古代知晓了孝道。与两位老人做游戏,并懂得了应该多陪伴父母,回归生活。本期穿越大讲堂为大家讲述了古今碰撞下的亲子关系。" }]上面是我们的配置表
然后这就读取下来 对 litJson 就是这么简便
在PC端可以 但是 在移动端我们怎么使用呢 博主 推荐是 MiniJson 和SimpleJSON
在此 博主项目使用的是SimpleJSON
public JSONNode jsonData;
IEnumerator LoadVideoJson(){string path= "";#if UNITY_ANDROID && !UNITY_EDITORpath = Application.streamingAssetsPath + "/" + "video.txt";#elsepath = "file://" + Application.streamingAssetsPath + "/" + "video.txt";#endifWWW www = new WWW (path);yield return www;if (www.isDone) {Debug.Log ("LoadVideoJson:" + www.text);jsonData = JSON.Parse (www.text);//Debug.Log (jsonData[1]["Image"]);SetJsonData ();}}这是用WWW 来读取txt 然后 赋值给jsonData
public void SetJsonData() { //if (myDataAll.Length > ui_Grid.childCount) //{ // Instantiate(btn_Prefab, ui_Grid.GetChild(ui_Grid.childCount).localPosition, Quaternion.identity); //}for (int i = 0; i < ui_Grid.childCount; i++)ui_Grid.GetChild (i).gameObject.SetActive (false);for (int i = 0; i < jsonData.Count; i++) { StartCoroutine(LoadPicture(i));ui_Grid.GetChild (i).gameObject.SetActive (true);ui_Grid.GetChild(i).GetChild(1).GetComponent<Text>().text = jsonData[i]["Name"] + ": " + jsonData[i]["Date"];ui_Grid.GetChild(i).GetChild(2).GetComponent<Text>().text = jsonData[i]["Note"]; } }
以下是jsonData 赋值
1 0
- 【Json】关于LitJson和相关Json的使用
- C#使用LitJson解析JSON
- C#使用LitJson解析JSON
- C#使用LitJson解析JSON
- C#使用LitJson解析JSON
- C#使用LitJson解析JSON
- C#使用LitJson解析JSON
- C#使用LitJson解析JSON
- C#使用LitJson解析JSON
- JSON库LitJSON的使用方法
- 使用LitJSON.dll处理json格式的数据示例
- Unity3d使用LitJson解析服务器上的JSON
- Unity3D使用LitJson解析服务器上的JSON
- LitJSON--json 和net 的完美组合用法
- LitJSON--json 和net 的完美组合用法
- [原创]Json学习--litjson的生成和…
- unity3d 使用LitJson解析 JSON格式数据
- C#使用LitJSON操作json数据
- 确定两串乱序同构
- Mysql 用户权限配置
- POJ1143位操作+状态压缩
- 关于ajax和iframe的个人总结和见解
- 使用zeranoe的自动化脚本mingw-w64-build-3.6.4在ubutun14.04_64bit上交叉编译ffmpeg 2.5
- 【Json】关于LitJson和相关Json的使用
- [HDU 5785] Interesting (Manacher+差分静态区间更新)
- html页面识别当前系统和语言
- 【HDU 5781】ATM Mechine(概率DP)
- HDU-2461 Rectangles(容斥原理)
- Scala中lazy关键字的使用和理解
- oracle常用的SQL PLUS命令详解
- 高通kernel 补丁网址
- 快速排序算法