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>
Wed, 9 Dec 2015 23:11:25 +0000 (18:11 -0500)
ecere/src/sys/JSON.ec

index a6bebd7..31c2913 100644 (file)
@@ -1009,6 +1009,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);
@@ -1023,6 +1028,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;
                      }
                   }
                }