using LitJson; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; public class JsonTest : MonoBehaviour { [HideInInspector] public Dictionary> cameraMoveTrans;//json中信息合集 // Start is called before the first frame update void Start() { cameraMoveTrans = ReadData("ErrorPosData.json"); foreach (var item in cameraMoveTrans) { for (int i = 0; i < item.Value.Count; i++) { Debug.Log(item.Key + "----------" + item.Value[i].Position + "----------" + item.Value[i].EulerAngles); } } } // Update is called once per frame void Update() { } /// /// 读json文件 /// /// /// private Dictionary> ReadData(string fileName) { Dictionary> tempDic = new Dictionary>(); string path = Path.Combine(Application.streamingAssetsPath, fileName); string data = File.ReadAllText(path); try { tempDic = JsonMapper.ToObject>>(data); return tempDic; } catch (LitJson.JsonException e) { //Debug.Log(e.Message); return null; } } }