forked from qt-creator/qt-creator
QmlDesigner: Fix the bug for importing json file
- Json objects are considered valid in the json arrays. - Json arrays are removed from the row objects. Fixes: QDS-11472 Change-Id: I89d7fb6d12952a994cf5e3aab0869154a3ab5d27 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Shrief Gabr <shrief.gabr@qt.io> Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
committed by
Mahmoud Badri
parent
11a84a8754
commit
8f6e90783c
@@ -33,8 +33,16 @@ QJsonArray loadAsSingleJsonCollection(const QUrl &url)
|
||||
auto refineJsonArray = [](const QJsonArray &array) -> QJsonArray {
|
||||
QJsonArray resultArray;
|
||||
for (const QJsonValue &collectionData : array) {
|
||||
if (!collectionData.isObject())
|
||||
resultArray.push_back(collectionData);
|
||||
if (collectionData.isObject()) {
|
||||
QJsonObject rowObject = collectionData.toObject();
|
||||
const QStringList rowKeys = rowObject.keys();
|
||||
for (const QString &key : rowKeys) {
|
||||
QJsonValue cellValue = rowObject.value(key);
|
||||
if (cellValue.isArray())
|
||||
rowObject.remove(key);
|
||||
}
|
||||
resultArray.push_back(rowObject);
|
||||
}
|
||||
}
|
||||
return resultArray;
|
||||
};
|
||||
|
Reference in New Issue
Block a user