switch back to json lohman - qtjson in new branch for more testing

This commit is contained in:
DenioD
2020-07-05 20:06:35 +02:00
parent 362e93f0b3
commit 460974f594
28 changed files with 19342 additions and 466 deletions

View File

@@ -59,16 +59,15 @@ void ChatDataStore::setPassword(QString password)
QString ChatDataStore::dump()
{
QJsonObject chats;
chats["count"] = (qint64)this->data.size();
QJsonArray j;
json chats;
chats["count"] = this->data.size();
json j = {};
for (auto &c: this->data)
{
j.push_back(c.second.toJson());
}
chats["chatitems"] = j;
QJsonDocument jd_chats = QJsonDocument(chats);
return QLatin1String(jd_chats.toJson(QJsonDocument::Compact));
return QString::fromStdString(chats.dump());
}
std::map<QString, ChatItem> ChatDataStore::getAllRawChatItems()

View File

@@ -1,6 +1,7 @@
#ifndef CHATDATASTORE_H
#define CHATDATASTORE_H
#include "../chatmodel.h"
using json = nlohmann::json;
class ChatDataStore
{

View File

@@ -33,9 +33,9 @@ ContactItem ContactDataStore::getData(QString key)
QString ContactDataStore::dump()
{
QJsonObject contacts;
contacts["count"] = (qint64)this->data.size();
QJsonArray j = {};
json contacts;
contacts["count"] = this->data.size();
json j = {};
for (auto &c: this->data)
{
qDebug() << c.second.toQTString();
@@ -43,10 +43,7 @@ QString ContactDataStore::dump()
j.push_back(c.second.toJson());
}
contacts["contacts"] = j;
QJsonDocument jd_contacts = QJsonDocument(contacts);
return QLatin1String(jd_contacts.toJson(QJsonDocument::Compact));
// return QString::fromStdString(contacts.dump(4));
return QString::fromStdString(contacts.dump(4));
}
ContactDataStore* ContactDataStore::instance = nullptr;

View File

@@ -2,6 +2,7 @@
#define CONTACTDATASTORE_H
#include "../Model/ContactItem.h"
#include <string>
using json = nlohmann::json;
class ContactDataStore
{

View File

@@ -1,6 +1,8 @@
#ifndef SIETCHDATASTORE_H
#define SIETCHDATASTORE_H
using json = nlohmann::json;
class SietchDataStore
{
private: