]> granicus.if.org Git - json-c/commitdiff
Fixed misalignment in JSON string due to space after \n being printed when choosing...
authorDarjan Krijan <darjan_krijan@gmx.de>
Tue, 20 Nov 2018 21:21:27 +0000 (22:21 +0100)
committerDarjan Krijan <darjan_krijan@gmx.de>
Tue, 20 Nov 2018 21:21:27 +0000 (22:21 +0100)
json_object.c

index 8a86bc6ea09a5e76995beb54c04b0af0961acfed..19f9c83c52e701f3d7b443198992e9683e3099c8 100644 (file)
@@ -395,7 +395,7 @@ static int json_object_object_to_json_string(struct json_object* jso,
                                printbuf_strappend(pb, "\n");
                }
                had_children = 1;
-               if (flags & JSON_C_TO_STRING_SPACED)
+               if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
                        printbuf_strappend(pb, " ");
                indent(pb, level+1, flags);
                printbuf_strappend(pb, "\"");
@@ -416,7 +416,7 @@ static int json_object_object_to_json_string(struct json_object* jso,
                        printbuf_strappend(pb, "\n");
                indent(pb,level,flags);
        }
-       if (flags & JSON_C_TO_STRING_SPACED)
+       if (flags & JSON_C_TO_STRING_SPACED && !(flags & JSON_C_TO_STRING_PRETTY))
                return printbuf_strappend(pb, /*{*/ " }");
        else
                return printbuf_strappend(pb, /*{*/ "}");