]> Git Repo - qemu.git/commitdiff
qjson: Drop trailing space for pretty formatting
authorMax Reitz <[email protected]>
Fri, 21 Nov 2014 09:29:59 +0000 (10:29 +0100)
committerKevin Wolf <[email protected]>
Wed, 10 Dec 2014 09:25:30 +0000 (10:25 +0100)
For the pretty formatting, the functions converting QDicts and QLists to
JSON should not print a space after the comma separating objects,
because a newline will emitted immediately afterwards, making the
whitespace superfluous.

Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
qobject/qjson.c

index 6cf2511580eec5aa5122f0c2684111b5dc0d24bb..12c576d548d1935b774e6d7419468e00ddaaeede 100644 (file)
@@ -86,8 +86,9 @@ static void to_json_dict_iter(const char *key, QObject *obj, void *opaque)
     QString *qkey;
     int j;
 
-    if (s->count)
-        qstring_append(s->str, ", ");
+    if (s->count) {
+        qstring_append(s->str, s->pretty ? "," : ", ");
+    }
 
     if (s->pretty) {
         qstring_append(s->str, "\n");
@@ -109,8 +110,9 @@ static void to_json_list_iter(QObject *obj, void *opaque)
     ToJsonIterState *s = opaque;
     int j;
 
-    if (s->count)
-        qstring_append(s->str, ", ");
+    if (s->count) {
+        qstring_append(s->str, s->pretty ? "," : ", ");
+    }
 
     if (s->pretty) {
         qstring_append(s->str, "\n");
This page took 0.026506 seconds and 4 git commands to generate.