1、导入litjson.dll 部分就不用说了
2、先附上我的json文件
{
"Web": [
{
"id": 1,
"name": "百度"
},
{
"id": 2,
"name": "搜狗"
},
{
"id": 3,
"name": "2345王牌浏览器"
}
]
}
3、附上我的解析代码
using System.Collections.Generic;
using UnityEngine;
using LitJson;
[System.Serializable]
public class Info
{
public int id;
public string name;
}
[System.Serializable]
public class jsonT
{
public List<Info> Web = new List<Info>();
}
public class JsonDemo : MonoBehaviour
{
public jsonT list = null;
public TextAsset jsonTextAsset;
private void Awake()
{
string str = jsonTextAsset.ToString();
list = JsonMapper.ToObject<jsonT>(str);
}
}
4、这种方法解析的时候需要注意
5、附上 我解析之后的截图