}
json_variant_dump(object,
- (mode == OUTPUT_JSON_SSE ? JSON_FORMAT_SSE :
- mode == OUTPUT_JSON_SEQ ? JSON_FORMAT_SEQ :
- mode == OUTPUT_JSON_PRETTY ? JSON_FORMAT_PRETTY :
- JSON_FORMAT_NEWLINE) |
+ output_mode_to_json_format_flags(mode) |
(FLAGS_SET(flags, OUTPUT_COLOR) ? JSON_FORMAT_COLOR : 0),
f, NULL);
#include "output-mode.h"
#include "string-table.h"
+JsonFormatFlags output_mode_to_json_format_flags(OutputMode m) {
+
+ switch (m) {
+
+ case OUTPUT_JSON_SSE:
+ return JSON_FORMAT_SSE;
+
+ case OUTPUT_JSON_SEQ:
+ return JSON_FORMAT_SEQ;
+
+ case OUTPUT_JSON_PRETTY:
+ return JSON_FORMAT_PRETTY;
+
+ default:
+ return JSON_FORMAT_NEWLINE;
+ }
+}
+
static const char *const output_mode_table[_OUTPUT_MODE_MAX] = {
[OUTPUT_SHORT] = "short",
[OUTPUT_SHORT_FULL] = "short-full",
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
+#include "json.h"
#include "macro.h"
typedef enum OutputMode {
OUTPUT_NO_HOSTNAME = 1 << 9,
} OutputFlags;
+JsonFormatFlags output_mode_to_json_format_flags(OutputMode m);
+
const char* output_mode_to_string(OutputMode m) _const_;
OutputMode output_mode_from_string(const char *s) _pure_;