45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#ifndef MAIN_H
|
|
#define MAIN_H
|
|
|
|
#include <QObject>
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
|
|
class Request : public QObject
|
|
{
|
|
|
|
public slots:
|
|
void showReply()
|
|
{
|
|
QJsonDocument jsonResponse = QJsonDocument::fromJson(doc.toUtf8());
|
|
QJsonObject jsonObject = jsonResponse.object();
|
|
QJsonArray jsonArray = jsonObject["response"].toArray();
|
|
int count = jsonArray.count();
|
|
for (int i=0; i<count; i++)
|
|
{
|
|
QJsonObject obj = jsonArray[i].toObject();
|
|
|
|
qDebug() << "regtype =" << obj["regtype"].toString();
|
|
qDebug() << "address =" << obj["address"].toInteger();
|
|
qDebug() << "name =" << obj["name"].toString();
|
|
qDebug() << "val_type =" << obj["val_type"].toString();
|
|
|
|
if (obj["val_type"].toString() == "long")
|
|
{
|
|
qDebug() << "value =" << obj["value"].toInteger();
|
|
}
|
|
else
|
|
{
|
|
qDebug() << "value =" << obj["value"].toDouble();
|
|
}
|
|
qDebug();
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
#endif // MAIN_H
|