JsonHelper.h 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

Don Gagne's avatar
Don Gagne committed
10 11 12 13 14 15 16 17 18 19 20

#ifndef JsonHelper_H
#define JsonHelper_H

#include <QJsonObject>
#include <QGeoCoordinate>

class JsonHelper
{
public:
    static bool validateRequiredKeys(const QJsonObject& jsonObject, const QStringList& keys, QString& errorString);
21
    static bool validateKeyTypes(const QJsonObject& jsonObject, const QStringList& keys, const QList<QJsonValue::Type>& types, QString& errorString);
Don Gagne's avatar
Don Gagne committed
22
    static bool toQGeoCoordinate(const QJsonValue& jsonValue, QGeoCoordinate& coordinate, bool altitudeRequired, QString& errorString);
Don Gagne's avatar
Don Gagne committed
23 24
    static bool parseEnum(QJsonObject& jsonObject, QStringList& enumStrings, QStringList& enumValues, QString& errorString);

25 26
    static void writeQGeoCoordinate(QJsonValue& jsonValue, const QGeoCoordinate& coordinate, bool writeAltitude);

Don Gagne's avatar
Don Gagne committed
27 28
    static const char*  _enumStringsJsonKey;
    static const char*  _enumValuesJsonKey;
Don Gagne's avatar
Don Gagne committed
29 30 31
};

#endif