fix: 修复 Json 解析报错的问题
							parent
							
								
									25d644328c
								
							
						
					
					
						commit
						6169adbcdb
					
				|  | @ -5,6 +5,7 @@ using System.Globalization; | |||
| using System.Linq; | ||||
| using System.Text; | ||||
| using Newtonsoft.Json; | ||||
| using Newtonsoft.Json.Linq; | ||||
| using UnityEngine; | ||||
| 
 | ||||
| 
 | ||||
|  | @ -326,19 +327,29 @@ namespace Guru | |||
|         { | ||||
|             //------- message send to unity ---------- | ||||
|             Debug.Log($"{Tag} get callback errorInfo:\n{msg}"); | ||||
| 
 | ||||
|             var result = JsonConvert.DeserializeObject<GuruLoggerCallback>(msg); | ||||
|             try | ||||
|             { | ||||
|                 if (result != null && result.action == ActionName) | ||||
|                 var data = JsonConvert.DeserializeObject<JObject>(msg); | ||||
|                 if (data.TryGetValue("action", out var jKey)) | ||||
|                 { | ||||
|                     if (result.data != null) | ||||
|                     if (jKey.ToString() == ActionName) | ||||
|                     { | ||||
|                         OnLoggerErrorEvent(result.data.code, result.data.msg); | ||||
|                         return; | ||||
|                         if (data.TryGetValue("code", out var jCode)) | ||||
|                         { | ||||
|                             int code = -1; | ||||
|                             string message = msg; | ||||
|                             int.TryParse(jCode.ToString(), out code); | ||||
|                          | ||||
|                             if (data.TryGetValue("msg", out var jMsg)) | ||||
|                             { | ||||
|                                 message = jMsg.ToString(); | ||||
|                             } | ||||
|                          | ||||
|                             OnLoggerErrorEvent(code, message); | ||||
|                             return; | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             | ||||
|                 Debug.LogError($"{Tag} Parse callback Error"); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|  | @ -374,30 +385,20 @@ namespace Guru | |||
|             Analytics.LogEvent("dev_audit", parameters, | ||||
|                 new Analytics.EventSetting() { EnableFirebaseAnalytics = true }); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|          | ||||
|         #endregion | ||||
|     } | ||||
| 
 | ||||
|     [Serializable] | ||||
|     internal class GuruLoggerCallback | ||||
|     { | ||||
|         public string action = ""; | ||||
|         public GuruLoggerErrorBody data; | ||||
|     } | ||||
|      | ||||
|     [Serializable] | ||||
|     internal class GuruLoggerErrorBody | ||||
|     { | ||||
|         public int code; | ||||
|         public string msg; | ||||
|     } | ||||
| 
 | ||||
|      | ||||
|      | ||||
|     /// <summary> | ||||
|     /// 网络状态枚举 | ||||
|     /// </summary> | ||||
|     public enum AnalyticsCode | ||||
|     { | ||||
|         Unknown = -1, | ||||
|          | ||||
|         Network_Lost = 22, | ||||
|          | ||||
|         ERROR_API = 101, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue