From: Darjan Krijan Date: Tue, 20 Nov 2018 21:21:27 +0000 (+0100) Subject: Fixed misalignment in JSON string due to space after \n being printed when choosing... X-Git-Tag: json-c-0.14-20200419~103^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8cec5c9e47676ebc51f1ab0af904fc4417b2166;p=json-c Fixed misalignment in JSON string due to space after \n being printed when choosing JSON_C_TO_STRING_SPACED together with JSON_C_TO_STRING_PRETTY in json_object_array_to_json_string --- diff --git a/json_object.c b/json_object.c index 8a86bc6..19f9c83 100644 --- a/json_object.c +++ b/json_object.c @@ -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, /*{*/ "}");