jsonanswer.cpp 394 B

123456789101112
  1. #include "jsonanswer.h"
  2. #include <QJsonDocument>
  3. QByteArray JsonAnswer::result() const
  4. {
  5. QByteArray objStr = QJsonDocument(m_obj).toJson(QJsonDocument::JsonFormat::Compact);
  6. QString result = "HTTP/1.1 200 OK\r\nContent-Type: application/json; charset=utf-8\r\n"
  7. "Content-Length: "+QString::number(objStr.size())+"\r\n\r\n" + objStr;
  8. return result.toUtf8();
  9. }