mirror of
https://github.com/JS8Call-improved/JS8Call-improved
synced 2026-08-13 17:47:36 -04:00
Improve message json serialization performance
This commit is contained in:
parent
e94bffb402
commit
89074e47f4
2 changed files with 16 additions and 8 deletions
20
Message.cpp
20
Message.cpp
|
|
@ -207,23 +207,27 @@ Message::read(QJsonObject const & json)
|
|||
void
|
||||
Message::write(QJsonObject & json) const
|
||||
{
|
||||
json["type"] = d_->type_;
|
||||
json["value"] = d_->value_;
|
||||
json["params"] = QJsonObject::fromVariantMap(d_->params_);
|
||||
toJsonObject().swap(json);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
// Conversions
|
||||
/******************************************************************************/
|
||||
|
||||
QJsonObject
|
||||
Message::toJsonObject() const
|
||||
{
|
||||
return {
|
||||
{ "type", d_->type_ },
|
||||
{ "value", d_->value_ },
|
||||
{ "params", QJsonObject::fromVariantMap(d_->params_) }
|
||||
};
|
||||
}
|
||||
|
||||
QByteArray
|
||||
Message::toJson() const
|
||||
{
|
||||
QJsonObject object;
|
||||
|
||||
write(object);
|
||||
|
||||
return QJsonDocument(object).toJson(QJsonDocument::Compact);
|
||||
return QJsonDocument(toJsonObject()).toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVariantMap
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue