From de0169abaa94d556cfd29d0c00320291ab630cb8 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 30 Sep 2016 11:01:50 -0700 Subject: [PATCH] Add new validateKeys support --- src/JsonHelper.cc | 22 ++++++++++++++++++++++ src/JsonHelper.h | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/src/JsonHelper.cc b/src/JsonHelper.cc index e1c4058ae..b15220ca9 100644 --- a/src/JsonHelper.cc +++ b/src/JsonHelper.cc @@ -262,3 +262,25 @@ void JsonHelper::saveGeoCoordinateArray(const QList& rgPoints } return saveGeoCoordinateArray(rgVarPoints, writeAltitude, jsonValue); } + +bool JsonHelper::validateKeys(const QJsonObject& jsonObject, const QList& keyInfo, QString& errorString) +{ + QStringList keyList; + QList typeList; + + for (int i=0; i& types, QString& errorString); + typedef struct { + const char* key; ///< json key name + QJsonValue::Type type; ///< type of key + bool required; ///< true: key must be present + } KeyValidateInfo; + + static bool validateKeys(const QJsonObject& jsonObject, const QList& keyInfo, QString& errorString); + /// Loads a QGeoCoordinate /// @return false: validation failed static bool loadGeoCoordinate(const QJsonValue& jsonValue, ///< json value to load from -- 2.22.0