summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2023-07-07 16:47:08 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2023-07-08 10:50:41 +0200
commit04f2acf93ad28848808822c9a8e0479509ec5555 (patch)
treec891b3fa64a2af119abb8f433f7417b48a56045c /qmake
parent7c25358144976d8f7b7d2b56f81782d607bb8cbf (diff)
qtpaths: generate proper JSON
The "manual" generation left a trailing comma in the object definition. This is illegal, as per RFC 8259: object = begin-object [ member *( value-separator member ) ] end-object Hence, the resulting JSON does not get accepted by any parser. Let's just not do that and use QJsonDocument. Change-Id: I882486e55f66c52d142638f37584088091bbc123 Pick-to: 6.2 6.5 6.6 Fixes: QTBUG-115124 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/propertyprinter.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/qmake/propertyprinter.cpp b/qmake/propertyprinter.cpp
index 4ba56327e6..10c94942e1 100644
--- a/qmake/propertyprinter.cpp
+++ b/qmake/propertyprinter.cpp
@@ -5,6 +5,10 @@
#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