46 lines
1005 B
C++
46 lines
1005 B
C++
#include "sjson.h"
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <QJsonArray>
|
|
#include <QDebug>
|
|
|
|
SJson::SJson()
|
|
{
|
|
|
|
}
|
|
|
|
SJson::~SJson()
|
|
{
|
|
|
|
}
|
|
|
|
QString SJson::Get(QString _str,QString _strKey)
|
|
{
|
|
return QJsonDocument::fromJson(_str.toUtf8()).object().value(_strKey).toString();
|
|
}
|
|
|
|
bool SJson::GetBool(QString _str,QString _strKey)
|
|
{
|
|
return QJsonDocument::fromJson(_str.toUtf8()).object().value(_strKey).toBool();
|
|
}
|
|
|
|
QString SJson::Set(QString _str,QString _strKey,QString _strValue)
|
|
{
|
|
QJsonDocument doc = QJsonDocument::fromJson(_str.toUtf8());
|
|
QJsonObject obj = doc.object();
|
|
obj.insert(_strKey,QJsonValue(_strValue));
|
|
doc.setObject(obj);
|
|
return doc.toJson();
|
|
}
|
|
|
|
QString SJson::Set(QString _str,QString _strKey,bool _bValue)
|
|
{
|
|
QJsonDocument doc = QJsonDocument::fromJson(_str.toUtf8());
|
|
QJsonObject obj = doc.object();
|
|
obj.insert(_strKey,QJsonValue(_bValue));
|
|
doc.setObject(obj);
|
|
return doc.toJson();
|
|
}
|
|
|
|
|