Unity3D 读取json
来源:互联网 发布:整容 知乎 编辑:程序博客网 时间:2024/06/05 06:49
本文固定链接:http://blog.csdn.net/u013108312/article/details/62046708
jsondLL下载: http://download.csdn.net/detail/duangufei/9482401
{ "height": 20, "sites": [ { "name": "testname", "age": 10, "data": [ 20, 12, 30, 55, 44 ] }, { "name": "google", "age": 18, "data": [ 20, 12, 30, 55, 44 ] }, { "name": "baidu", "age": 30, "data": [ 20, 12, 30, 55, 44 ] } ]}
using System.Collections;using System.Collections.Generic;using UnityEngine;using LitJson;public class ReadJson : MonoBehaviour { // Use this for initialization void Start () { TextAsset text = Resources.Load<TextAsset>("jsonTest"); tmxClass jd = JsonMapper.ToObject<tmxClass>(text.text); for (int i = 0; i < jd.sites.Count; i++) { Debug.Log(jd.sites[i].name + "/" + jd.sites[i].data.Count); } #region 测试1 /* TextAsset text = Resources.Load<TextAsset>("jsonTest"); Hashtable jd = JsonMapper.ToObject<Hashtable>(text.text); JsonData jd1 = jd["sites"] as JsonData; for (int i = 0; i < jd1.Count; i++) { Debug.Log(jd1[i]["name"]); } Debug.Log("ht = " + jd["sites"].ToString()); Debug.Log("ht = " + jd1.Count); Debug.Log("text :" + text.text); //string json = "{\"test\":\"www.test\",\"test1\":\"www.test1\"}"; //Hashtable jd = JsonMapper.ToObject<Hashtable>(json); //foreach (string str in jd.Keys) //{ // Debug.Log("key = " + str + "/value = " + jd[str]); //} //Debug.Log("jd test = " + jd["test"]); */ #endregion } public class sites { public string name; public int age; public List<int> data; } public class tmxClass { public int height; public List<sites> sites; }}
1 0
- Unity3D 读取json
- Unity3d 读取json文本数据
- Unity3D——LitJson解析json,读取关卡信息
- Json 读取
- 读取Json
- json读取
- 读取json
- 读取json
- unity3d学习笔记(二十)--利用JSON读取和保存游戏数据
- unity3d学习笔记(二十)--利用JSON读取和保存游戏数据
- unity3D学习【功能实现】之十一:通过Json读取地图01
- 读取json 读取本地文件
- unity3d读取XML配置文件
- unity3d读取csv文件
- Unity3d读取.csv文件
- unity3d读取csv文件
- Unity3d 读取 Sqlite数据库
- unity3d 读取文本文件
- 是否完全二叉搜索树
- Linux系统下强制踢掉登录用户
- 第3节 C语言的优点与缺点
- SSH框架学习心得
- Python脚本实现自动下载apk文件
- Unity3D 读取json
- B1009
- Caffe学习系列(11):图像数据转换成db(leveldb/lmdb)文件
- 走进 Redis 的世界
- kvm性能优化方案---cpu/内存/磁盘/网络
- 程序的实现过程(编译、链接、执行)
- Elasticsearch的基础教程
- ionic 滑动块 ion-slide-box 左右无缝滚动
- Android 自定义ViewGroup中onFinishInflate方法可以用来干什么