@@ -956,20 +956,28 @@ void JsonAPI::handleConfigGetCommand(const QJsonObject &message, const JsonApiCo
956956 {
957957 QStringList globalFilterTypes;
958958
959- const QJsonObject globalConfig = filter[" global" ]. toObject () ;
960- if (! globalConfig.isEmpty ())
959+ const QJsonValue globalConfig = filter[" global" ];
960+ if (globalConfig.isNull ())
961961 {
962- QJsonValue const globalTypes = globalConfig[ " types " ] ;
963- if (globalTypes. isNull ())
964- {
965- globalFilterTypes. append ( " __none__ " );
966- }
967- else
962+ globalFilterTypes. append ( " __none__ " ) ;
963+ }
964+ else
965+ {
966+ const QJsonObject globalConfigObject = globalConfig. toObject ();
967+ if (!globalConfigObject. isEmpty ())
968968 {
969- QJsonArray const globalTypesList = globalTypes.toArray ();
970- for (const auto &type : globalTypesList) {
971- if (type.isString ()) {
972- globalFilterTypes.append (type.toString ());
969+ QJsonValue const globalTypes = globalConfig[" types" ];
970+ if (globalTypes.isNull ())
971+ {
972+ globalFilterTypes.append (" __none__" );
973+ }
974+ else
975+ {
976+ QJsonArray const globalTypesList = globalTypes.toArray ();
977+ for (const auto &type : globalTypesList) {
978+ if (type.isString ()) {
979+ globalFilterTypes.append (type.toString ());
980+ }
973981 }
974982 }
975983 }
@@ -978,43 +986,51 @@ void JsonAPI::handleConfigGetCommand(const QJsonObject &message, const JsonApiCo
978986 QList<quint8> instanceListFilter;
979987 QStringList instanceFilterTypes;
980988
981- const QJsonObject instances = filter[" instances" ]. toObject () ;
982- if (! instances.isEmpty ())
989+ const QJsonValue instances = filter[" instances" ];
990+ if (instances.isNull ())
983991 {
984- QSet<quint8> const configuredInstanceIds = _instanceManager->getInstanceIds ();
985- QJsonValue const instanceIds = instances[" ids" ];
986- if (instanceIds.isNull ())
987- {
988- instanceListFilter.append (NO_INSTANCE_ID);
989- }
990- else
992+ instanceListFilter.append (NO_INSTANCE_ID);
993+ }
994+ else
995+ {
996+ const QJsonObject instancesObject = instances.toObject ();
997+ if (!instancesObject.isEmpty ())
991998 {
992- QJsonArray const instaceIdsList = instanceIds.toArray ();
993- for (const auto &idx : instaceIdsList) {
994- if (idx.isDouble ()) {
995- quint8 const instanceId = static_cast <quint8>(idx.toInt ());
996- if (configuredInstanceIds.contains (instanceId))
997- {
998- instanceListFilter.append (instanceId);
999- }
1000- else
1001- {
1002- errorDetails.append (QString (" Given instance number '%1' does not exist." ).arg (instanceId));
1003- }
1004- }
1005- }
1006-
1007- QJsonValue const instanceTypes = instances[" types" ];
1008- if (instanceTypes.isNull ())
999+ QSet<quint8> const configuredInstanceIds = _instanceManager->getInstanceIds ();
1000+ QJsonValue const instanceIds = instances[" ids" ];
1001+ if (instanceIds.isNull ())
10091002 {
1010- instanceFilterTypes .append (" __none__ " );
1003+ instanceListFilter .append (NO_INSTANCE_ID );
10111004 }
10121005 else
10131006 {
1014- QJsonArray const instaceTypesList = instanceTypes.toArray ();
1015- for (const auto &type : instaceTypesList) {
1016- if (type.isString ()) {
1017- instanceFilterTypes.append (type.toString ());
1007+ QJsonArray const instaceIdsList = instanceIds.toArray ();
1008+ for (const auto &idx : instaceIdsList) {
1009+ if (idx.isDouble ()) {
1010+ quint8 const instanceId = static_cast <quint8>(idx.toInt ());
1011+ if (configuredInstanceIds.contains (instanceId))
1012+ {
1013+ instanceListFilter.append (instanceId);
1014+ }
1015+ else
1016+ {
1017+ errorDetails.append (QString (" Given instance number '%1' does not exist." ).arg (instanceId));
1018+ }
1019+ }
1020+ }
1021+
1022+ QJsonValue const instanceTypes = instances[" types" ];
1023+ if (instanceTypes.isNull ())
1024+ {
1025+ instanceFilterTypes.append (" __none__" );
1026+ }
1027+ else
1028+ {
1029+ QJsonArray const instaceTypesList = instanceTypes.toArray ();
1030+ for (const auto &type : instaceTypesList) {
1031+ if (type.isString ()) {
1032+ instanceFilterTypes.append (type.toString ());
1033+ }
10181034 }
10191035 }
10201036 }
0 commit comments