ecere/sys/JSON: Avoiding confusion by letting WriteNumber() add the quotes for JSON...
authorJerome St-Louis <jerome@ecere.com>
Sun, 24 Apr 2016 02:52:16 +0000 (22:52 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 28 Jul 2016 22:23:18 +0000 (18:23 -0400)
ecere/src/sys/JSON.ec

index 4e9052b..d1a0d6d 100644 (file)
@@ -1247,7 +1247,8 @@ static bool WriteNumber(File f, Class type, DataValue value, int indent, bool eC
    else if(!strcmp(type.dataTypeString, "unsigned char") || !strcmp(type.dataTypeString, "byte") || type.typeSize == sizeof(byte))
       ((const char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &value.uc, buffer, null, &needClass);
 
-   quote = (type.type == unitClass && ((buffer[0] != '.' && !isdigit(buffer[0])) || strchr(buffer, ' ')));
+   quote = (type.type == unitClass && ((buffer[0] != '.' && !isdigit(buffer[0])) || strchr(buffer, ' '))) ||
+           (type.type == enumClass && !eCON);
    if(quote) f.Puts("\"");
    f.Puts(buffer);
    if(quote) f.Puts("\"");
@@ -1403,13 +1404,7 @@ static bool WriteValue(File f, Class type, DataValue value, int indent, bool eCO
          f.Puts("unset");
    }
    else if(type.type == enumClass)
-   {
-      if(!eCON)
-         f.Puts("\"");
       WriteNumber(f, type, value, indent, eCON);
-      if(!eCON)
-         f.Puts("\"");
-   }
    else if(eClass_IsDerived(type, class(Map)))
    {
       WriteMap(f, type, value.p, indent, eCON);