private void LoadJsonData(string text, JsonDllType dllType) { if (string.IsNullOrEmpty(text)) { return; } Profiler.BeginSample("BattleJsonTest"); try { try { switch (dllType) { case JsonDllType.LitJson: m_RoundData = LitJson.JsonMapper.ToObject <BattleRoundData>(text); break; case JsonDllType.NewtonJson: m_RoundData = Newtonsoft.Json.JsonConvert.DeserializeObject <BattleRoundData>(text); break; case JsonDllType.fastJson: m_RoundData = fastJSON.JSON.ToObject <BattleRoundData>(text); break; } } catch (Exception e) { Debug.LogError(e.ToString()); } } finally { Profiler.EndSample(); } }
private void LoadJsonFromFile(string fileName, JsonDllType dllType) { if (string.IsNullOrEmpty(fileName)) { return; } var asset = Resources.Load <TextAsset>(fileName); if (asset == null) { return; } string text = asset.text; LoadJsonData(text, dllType); }