32 lines
892 B
C++
32 lines
892 B
C++
#ifndef JSONPARSER_H
|
|
#define JSONPARSER_H
|
|
|
|
#include <QVariant>
|
|
|
|
class QJsonObject;
|
|
class QString;
|
|
class QByteArray;
|
|
class QJsonArray;
|
|
|
|
typedef QHash<int, QVariant> ModelItemValues;
|
|
|
|
using namespace std;
|
|
|
|
class JsonParser {
|
|
public:
|
|
static QList<ModelItemValues> toItemValuesList(const QByteArray& jsonData,
|
|
const QString& objectName = "");
|
|
static QByteArray itemValuesListToJson(const QList<ModelItemValues>& itemValuesList,
|
|
const QString& objectName = "");
|
|
|
|
private:
|
|
explicit JsonParser();
|
|
|
|
static QJsonArray extractItemArray(const QByteArray& jsonData, const QString& objectName);
|
|
static ModelItemValues jsonObjectToItemValues(const QJsonObject& itemJsonObject);
|
|
|
|
static pair<int, QVariant> getKeyValuePair(const QJsonObject& itemJsonObject, const int role);
|
|
};
|
|
|
|
#endif // JSONPARSER_H
|