diff options
Diffstat (limited to 'qmake/propertyprinter.cpp')
-rw-r--r-- | qmake/propertyprinter.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/qmake/propertyprinter.cpp b/qmake/propertyprinter.cpp index 6ba2f76363..52a790e2c8 100644 --- a/qmake/propertyprinter.cpp +++ b/qmake/propertyprinter.cpp @@ -1,16 +1,20 @@ // 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) { // Assume single property request - if (values.count() == 1) { + if (values.size() == 1) { std::cout << qPrintable(values.at(0).second) << std::endl; return; } @@ -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 |