ecere/sys/JSON: Fixed support for writing struct properties
authorJerome St-Louis <jerome@ecere.com>
Mon, 16 Mar 2015 02:59:00 +0000 (22:59 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 15 Oct 2015 00:19:34 +0000 (20:19 -0400)
ecere/src/sys/JSON.ec

index 9d29feb..c406d47 100644 (file)
@@ -1010,6 +1010,11 @@ static bool _WriteJSONObject(File f, Class objectType, void * object, int indent
                         {
                            value.c = ((char (*)(void *))(void *)prop.Get)(object);
                         }
+                        else if(type.type == structClass)
+                        {
+                           value.p = new byte[type.structSize];
+                           ((void (*)(void *, void *))(void *)prop.Get)(object, value.p);
+                        }
                         else
                         {
                            value.p = ((void *(*)(void *))(void *)prop.Get)(object);
@@ -1024,6 +1029,8 @@ static bool _WriteJSONObject(File f, Class objectType, void * object, int indent
                         f.Puts("\" : ");
                         WriteValue(f, type, value, indent);
                         isFirst = false;
+                        if(type.type == structClass)
+                           delete value.p;
                      }
                   }
                }