Esempio n. 1
0
        void LoadData()
        {
            string filepath = Application.dataPath + "/Resources/JsonFiles/role.json";

            if (!File.Exists(filepath))
            {
                Debug.Log(filepath + "do not exist");
                return;
            }
            StreamReader sr = new StreamReader(filepath);

            if (sr == null)
            {
                Debug.Log(filepath + "read failed");
                return;
            }
            string json = sr.ReadToEnd();

            if (json.Length > 0)
            {
                _roleDataList = JsonUtility.FromJson <RoleDataList> (json);
            }
            else
            {
                Debug.Log(filepath + "empty file");
            }
            //Debug.Log (_roleDataList.roleDataList.Length.ToString());
        }
Esempio n. 2
0
        private void DeserializeRoleDataJson()
        {
            string path = Application.dataPath + "/Resources/Json/" + m_roleDataJsonFileName + ".json";
            string json = File.ReadAllText(path);

            roleDataList = JsonConvert.DeserializeObject <RoleDataList>(json);
        }
Esempio n. 3
0
        public JsonResult GetRole()
        {
            //
            StatusData myStatusData = new StatusData();//返回状态
            //
            RoleDataList myData = new RoleDataList();

            try
            {
                myStatusData.operateStatus = 200;
                myStatusData.dataTable     = myData;
            }
            catch
            {
                myStatusData.operateStatus = -1;
            }
            return(Json(myStatusData));
        }