aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2014-11-21 10:29:59 +0100
committerKevin Wolf <kwolf@redhat.com>2014-12-10 10:25:30 +0100
commit4b58554a0e60aba6f1c6f391759f148f7bca181b (patch)
treede86c4ccf5d777d2856baa1a92363fa082d2723d
parentf71eaa74c0bf2cf9da9a00b571d4b8162c61e29d (diff)
downloadqemu-4b58554a0e60aba6f1c6f391759f148f7bca181b.zip
qemu-4b58554a0e60aba6f1c6f391759f148f7bca181b.tar.gz
qemu-4b58554a0e60aba6f1c6f391759f148f7bca181b.tar.bz2
qjson: Drop trailing space for pretty formatting
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 <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--qobject/qjson.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/qobject/qjson.c b/qobject/qjson.c
index 6cf2511..12c576d 100644
--- a/qobject/qjson.c
+++ b/qobject/qjson.c
@@ -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");