[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/73] qjson: Drop trailing space for pretty formatti
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 05/73] qjson: Drop trailing space for pretty formatting |
Date: |
Wed, 10 Dec 2014 11:33:31 +0100 |
From: Max Reitz <address@hidden>
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qobject/qjson.c | 10 ++++++----
1 file 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");
--
1.8.3.1
- [Qemu-devel] [PULL 66/73] block: remove BLOCK_OPT_NOCOW from vpc_create_opts, (continued)
- [Qemu-devel] [PULL 66/73] block: remove BLOCK_OPT_NOCOW from vpc_create_opts, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 68/73] vmdk: Use g_random_int to generate CID, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 69/73] vmdk: Fix comment to match code of extent lines, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 71/73] vmdk: Check descriptor file length when reading it, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 70/73] vmdk: Clean up descriptor file reading, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 67/73] block: Use g_new0() for a bit of extra type checking, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 73/73] vmdk: Set errp on failures in vmdk_open_vmdk4, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 72/73] vmdk: Remove unnecessary initialization, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 64/73] qemu-iotests: Skip 099 for VMDK subformats with desc file, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 43/73] qcow2.py: Add required padding for header extensions, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 05/73] qjson: Drop trailing space for pretty formatting,
Kevin Wolf <=
- [Qemu-devel] [PULL 59/73] iotests: Add test for unsupported image creation, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 12/73] blockdev: acquire AioContext in change-backing-file, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 04/73] qmp: Add optional switch "query-nodes" in query-blockstats, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 18/73] blkdebug: Simplify and improve filename generation, Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 33/73] block: Factor bdrv_probe_all() out of find_image_format(), Kevin Wolf, 2014/12/10
- [Qemu-devel] [PULL 08/73] iotests: Use -qmp-pretty in 067, Kevin Wolf, 2014/12/10
- Re: [Qemu-devel] [PULL 00/73] Merging block-next for 2.3, Peter Maydell, 2014/12/11