int ManagedJsonDb::insertRec(QString in, QString aus, QString commentin, QString commentaus) { QJsonObject jObj; jObj["inland"] = in; jObj["ausland"] = aus; jObj["commentin"] = commentin; jObj["commentaus"] = commentaus; jObj["rightt"] = 0; jObj["wrong"] = 0; // Open the file QFile database(pathToJson); if(!database.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append)){ qDebug() << "Couldn't open save file"; return -1; } QTextStream out(&database); QJsonDocument jDoc(jObj); out << jDoc.toJson(); out.flush(); database.close(); return 1; }
void wsServer::clientMessage(QJsonObject json){ QJsonDocument jDoc(json); for(int i =0;i<m_clients.length();i++) m_clients[i]->sendTextMessage(QString::fromUtf8(jDoc.toJson())); }
void logger::logMessage(QJsonObject json){ QDateTime time = QDateTime::currentDateTime(); QJsonDocument jDoc(json); QTextStream(stdout)<<time.toString("dd.MM.yyyy hh:mm:ss.zzz")<<" "<<QString::fromUtf8(jDoc.toJson())<<endl; }