VirtualBox

Changeset 73614 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Aug 10, 2018 12:15:14 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9152: Export Appliance wizard: Adjust JSON parser to handle item arrays with complex (object) types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/wizards/exportappliance/UIWizardExportAppPageBasic3.cpp

    r73613 r73614  
    211211    AssertMsgReturn(field.isArray(), ("Field '%s' has wrong structure!", strFieldName.toUtf8().constData()), QStringList());
    212212    const QJsonArray fieldValueArray = field.toArray();
    213     QStringList fieldValueStirngList;
     213    QStringList fieldValueStringList;
     214    /* Parse array: */
    214215    for (int i = 0; i < fieldValueArray.count(); ++i)
    215             fieldValueStirngList << fieldValueArray[i].toString();
    216     //printf("  Field value: \"%s\"\n", fieldValueStirngList.join(", ").toUtf8().constData());
    217 
    218     return fieldValueStirngList;
     216    {
     217        /* Parse current array value: */
     218        const QJsonValue value = fieldValueArray[i];
     219        /* If value is of string type, we just take it: */
     220        if (value.isString())
     221            fieldValueStringList << fieldValueArray[i].toString();
     222        /* If value is of object type, we just take object values only: */
     223        else if (value.isObject())
     224        {
     225            const QJsonObject valueObject = value.toObject();
     226            foreach (const QString &strKey, valueObject.keys())
     227                fieldValueStringList << valueObject.value(strKey).toString();
     228        }
     229    }
     230    //printf("  Field value: \"%s\"\n", fieldValueStringList.join(", ").toUtf8().constData());
     231
     232    return fieldValueStringList;
    219233}
    220234
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette