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 Fixes: QTBUG-115124 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 04f2acf93ad28848808822c9a8e0479509ec5555) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
0bbaef3edc
commit
000c78747f
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user