* json doesn't need to escape singlequotes
[citadel.git] / libcitadel / lib / json.c
index 044be9cdf38b338d83a9c57f7bb52bae863a94f4..8690f4e2b7b3d851fbc86e281b766d914de19339 100644 (file)
@@ -179,7 +179,7 @@ void JsonObjectAppend(JsonValue *Array, JsonValue *Val)
 
 
 
-void SerializeJson(StrBuf *Target, JsonValue *Val)
+void SerializeJson(StrBuf *Target, JsonValue *Val, int FreeVal)
 {
        void *vValue, *vPrevious;
        JsonValue *SubVal;
@@ -215,7 +215,7 @@ void SerializeJson(StrBuf *Target, JsonValue *Val)
                                StrBufAppendBufPlain(Target, HKEY(","), 0);
 
                        SubVal = (JsonValue*) vValue;
-                       SerializeJson(Target, SubVal);
+                       SerializeJson(Target, SubVal, 0);
                        vPrevious = vValue;
                }
                StrBufAppendBufPlain(Target, HKEY("]"), 0);
@@ -237,13 +237,15 @@ void SerializeJson(StrBuf *Target, JsonValue *Val)
                        StrBufAppendBuf(Target, SubVal->Name, 0);
                        StrBufAppendBufPlain(Target, HKEY("\":"), 0);
 
-                       SerializeJson(Target, SubVal);
+                       SerializeJson(Target, SubVal, 0);
                        vPrevious = vValue;
                }
                StrBufAppendBufPlain(Target, HKEY("}"), 0);
                break;
        }
-
+       if(FreeVal) {
+               DeleteJSONValue(Val);
+       }
 }