diff options
Diffstat (limited to 'qmake/propertyprinter.cpp')
-rw-r--r-- | qmake/propertyprinter.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/qmake/propertyprinter.cpp b/qmake/propertyprinter.cpp index 4ba56327e6..52a790e2c8 100644 --- a/qmake/propertyprinter.cpp +++ b/qmake/propertyprinter.cpp @@ -1,10 +1,14 @@ // Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "propertyprinter.h" #include <iostream> +#include <QJsonDocument> +#include <QJsonObject> +#include <QJsonValue> + QT_BEGIN_NAMESPACE void qmakePropertyPrinter(const QList<QPair<QString, QString>> &values) @@ -22,11 +26,12 @@ void qmakePropertyPrinter(const QList<QPair<QString, QString>> &values) void jsonPropertyPrinter(const QList<QPair<QString, QString>> &values) { - std::cout << "{\n"; - for (const auto &val : values) { - std::cout << "\"" << qPrintable(val.first) << "\":\"" << qPrintable(val.second) << "\",\n"; - } - std::cout << "}\n"; + QJsonObject object; + for (const auto &val : values) + object.insert(val.first, val.second); + + QJsonDocument document(object); + std::cout << document.toJson().constData(); } QT_END_NAMESPACE |