qjson: Drop trailing space for pretty formatting
PATCH 1/1 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.
--- qobject/qjson.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
qobject/qjson.c +6 -4
@@ -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" );
Signature · 1 line
1.9.3
Am 21.11.2014 um 10:29 hat Max Reitz geschrieben:
Quoted 6 lines
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]>
Luiz, any objections?
/me waits a bit... 3... 2... 1...
No? Great, thanks, applied to block-next.
(More seriously, I have a patch with a qemu-iotests case depending on the output, so I'm merging this before my patch. If there is a problem, there's still some time until block-next ends up in master, so I can always drop it or replace it with a v2.)
Kevin
Quoted 10 lines · Max Reitz
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]>--- qobject/qjson.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org