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>
This commit is contained in:
parent
f71eaa74c0
commit
4b58554a0e
@ -86,8 +86,9 @@ static void to_json_dict_iter(const char *key, QObject *obj, void *opaque)
|
|||||||
QString *qkey;
|
QString *qkey;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
if (s->count)
|
if (s->count) {
|
||||||
qstring_append(s->str, ", ");
|
qstring_append(s->str, s->pretty ? "," : ", ");
|
||||||
|
}
|
||||||
|
|
||||||
if (s->pretty) {
|
if (s->pretty) {
|
||||||
qstring_append(s->str, "\n");
|
qstring_append(s->str, "\n");
|
||||||
@ -109,8 +110,9 @@ static void to_json_list_iter(QObject *obj, void *opaque)
|
|||||||
ToJsonIterState *s = opaque;
|
ToJsonIterState *s = opaque;
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
if (s->count)
|
if (s->count) {
|
||||||
qstring_append(s->str, ", ");
|
qstring_append(s->str, s->pretty ? "," : ", ");
|
||||||
|
}
|
||||||
|
|
||||||
if (s->pretty) {
|
if (s->pretty) {
|
||||||
qstring_append(s->str, "\n");
|
qstring_append(s->str, "\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user