GCC_FMT_ATTR(1, 2);
QString *qobject_to_json(const QObject *obj);
-QString *qobject_to_json_pretty(const QObject *obj);
+QString *qobject_to_json_pretty(const QObject *obj, bool pretty);
#endif /* QJSON_H */
const QObject *data = QOBJECT(rsp);
QString *json;
- json = mon->pretty ? qobject_to_json_pretty(data) : qobject_to_json(data);
+ json = qobject_to_json_pretty(data, mon->pretty);
assert(json != NULL);
qstring_append_chr(json, '\n');
visit_type_ImageCheck(v, NULL, &check, &error_abort);
visit_complete(v, &obj);
- str = qobject_to_json_pretty(obj);
+ str = qobject_to_json_pretty(obj, true);
assert(str != NULL);
qprintf(quiet, "%s\n", qstring_get_str(str));
qobject_unref(obj);
visit_type_ImageInfoList(v, NULL, &list, &error_abort);
visit_complete(v, &obj);
- str = qobject_to_json_pretty(obj);
+ str = qobject_to_json_pretty(obj, true);
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_unref(obj);
visit_type_ImageInfo(v, NULL, &info, &error_abort);
visit_complete(v, &obj);
- str = qobject_to_json_pretty(obj);
+ str = qobject_to_json_pretty(obj, true);
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_unref(obj);
visit_type_BlockMeasureInfo(v, NULL, &info, &error_abort);
visit_complete(v, &obj);
- str = qobject_to_json_pretty(obj);
+ str = qobject_to_json_pretty(obj, true);
assert(str != NULL);
printf("%s\n", qstring_get_str(str));
qobject_unref(obj);
return qdict;
}
-static void to_json(const QObject *obj, QString *str, int pretty, int indent);
-
static void json_pretty_newline(QString *str, bool pretty, int indent)
{
int i;
}
}
-static void to_json(const QObject *obj, QString *str, int pretty, int indent)
+static void to_json(const QObject *obj, QString *str, bool pretty, int indent)
{
switch (qobject_type(obj)) {
case QTYPE_QNULL:
}
}
-QString *qobject_to_json(const QObject *obj)
+QString *qobject_to_json_pretty(const QObject *obj, bool pretty)
{
QString *str = qstring_new();
- to_json(obj, str, 0, 0);
+ to_json(obj, str, pretty, 0);
return str;
}
-QString *qobject_to_json_pretty(const QObject *obj)
+QString *qobject_to_json(const QObject *obj)
{
- QString *str = qstring_new();
-
- to_json(obj, str, 1, 0);
-
- return str;
+ return qobject_to_json_pretty(obj, false);
}
QObject *obj = qmp_qom_get(path, property, &err);
if (err == NULL) {
- QString *str = qobject_to_json_pretty(obj);
+ QString *str = qobject_to_json_pretty(obj, true);
monitor_printf(mon, "%s\n", qstring_get_str(str));
qobject_unref(str);
}
g_assert(response);
if (!qdict_haskey(response, "return")) {
- QString *s = qobject_to_json_pretty(QOBJECT(response));
+ QString *s = qobject_to_json_pretty(QOBJECT(response), true);
g_test_message("%s", qstring_get_str(s));
qobject_unref(s);
}