Przeglądaj źródła

Fixed JsonDeserializer to handle System.Text.Json.Nodes.JsonNode

vpenades 2 lat temu
rodzic
commit
7fcc6f11ca
1 zmienionych plików z 7 dodań i 1 usunięć
  1. 7 1
      src/SharpGLTF.Core/IO/JsonSerializable.cs

+ 7 - 1
src/SharpGLTF.Core/IO/JsonSerializable.cs

@@ -488,7 +488,7 @@ namespace SharpGLTF.IO
             var ntype = Nullable.GetUnderlyingType(vtype);
             if (ntype != null) vtype = ntype;
 
-            // known types
+            // known types            
 
             if (vtype == typeof(String)) { value = reader.AsString(); return true; }
             if (vtype == typeof(Boolean)) { value = reader.AsBoolean(); return true; }
@@ -551,6 +551,12 @@ namespace SharpGLTF.IO
                 return true;
             }
 
+            if (typeof(System.Text.Json.Nodes.JsonNode).IsAssignableFrom(vtype))
+            {
+                value = System.Text.Json.Nodes.JsonNode.Parse(ref reader);
+                return true;
+            }
+
             if (typeof(JsonSerializable).IsAssignableFrom(vtype))
             {
                 var item = Activator.CreateInstance(vtype, true) as JsonSerializable;