فهرست منبع

json-bug修复-Null值处理

lvjincheng 3 سال پیش
والد
کامیت
0fffba0748
1فایلهای تغییر یافته به همراه2 افزوده شده و 0 حذف شده
  1. 2 0
      Assets/ThirdAssets/JCUnityLib/CustomJson.cs

+ 2 - 0
Assets/ThirdAssets/JCUnityLib/CustomJson.cs

@@ -89,6 +89,7 @@ namespace JCUnityLib
 
         public JToken ToJTokenByImporter(object o)
         {
+            if (o == null) return null;
             Type type = o.GetType();
             Func<object, JToken> importer = null;
             importerDict.TryGetValue(type, out importer);
@@ -115,6 +116,7 @@ namespace JCUnityLib
 
         public object ParseByExporter(JToken jt, Type type)
         {
+            if (jt.Type == JTokenType.Null) return null;
             Func<JToken, object> exporter = null;
             exporterDict.TryGetValue(type, out exporter);
             if (exporter == null) {