fputs(name ? ",\n" : ",", fmt->out);
}
- if (fmt->json_format == UL_JSON_LINE) {
- /* do nothing */
- } else if (fmt->json_format == UL_JSON_COMPACT) {
- /* do nothing */
- } else {
+ switch (fmt->json_format) {
+ case UL_JSON_LINE:
+ case UL_JSON_COMPACT:
+ break;
+ case UL_JSON_PRETTY:
+ default:
if (name || !fmt->after_close)
ul_jsonwrt_indent(fmt);
+ break;
}
if (name)
fputs_quoted_json_lower(name, fmt->out);
case UL_JSON_OBJECT:
if (fmt->json_format == UL_JSON_LINE)
s = "{";
- else if (fmt->json_format == UL_JSON_COMPACT)
+ else if (fmt->json_format == UL_JSON_COMPACT) {
if (fmt->indent == 2)
s = name ? ":{" : "\n{";
else
s = "{";
- else
+ } else
s = name ? ": {\n" : "{\n";
fmt->indent++;
break;
if (fmt->json_format == UL_JSON_COMPACT && fmt->indent == 1)
fputc('\n', fmt->out);
- if (fmt->json_format == UL_JSON_LINE) {
- /* do nothing */
- } else if (fmt->json_format == UL_JSON_COMPACT) {
- /* do nothing */
- } else {
+ switch (fmt->json_format) {
+ case UL_JSON_LINE:
+ case UL_JSON_COMPACT:
+ break;
+ case UL_JSON_PRETTY:
+ default:
fputs("\n", fmt->out);
ul_jsonwrt_indent(fmt);
+ break;
}
+
fputc(endchr, fmt->out);
- if (fmt->json_format == UL_JSON_LINE) {
- /* do nothing */
- } else if (fmt->json_format == UL_JSON_COMPACT) {
- if (fmt->indent == 0)
- fputc('\n', fmt->out);
- } else {
+
+ switch (fmt->json_format) {
+ case UL_JSON_LINE:
+ break;
+ case UL_JSON_COMPACT:
+ case UL_JSON_PRETTY:
+ default:
if (fmt->indent == 0)
fputc('\n', fmt->out);
+ break;
}
fmt->after_close = 1;
}