mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
refs #192, enable value objects for JSON:
* from/toJson methods * jsonMembers where applicable
This commit is contained in:
@@ -91,6 +91,32 @@ namespace BlackMisc
|
||||
qDBusRegisterMetaType<CInformationMessage>();
|
||||
}
|
||||
|
||||
/*
|
||||
* JSON members
|
||||
*/
|
||||
const QStringList &CInformationMessage::jsonMembers()
|
||||
{
|
||||
return TupleConverter<CInformationMessage>::jsonMembers();
|
||||
}
|
||||
|
||||
/*
|
||||
* To JSON
|
||||
*/
|
||||
QJsonObject CInformationMessage::toJson() const
|
||||
{
|
||||
return BlackMisc::serializeJson(CInformationMessage::jsonMembers(), TupleConverter<CInformationMessage>::toTuple(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* To JSON
|
||||
*/
|
||||
void CInformationMessage::fromJson(const QJsonObject &json)
|
||||
{
|
||||
this->m_message = json.value("m_message").toString();
|
||||
this->m_type = static_cast<CInformationMessage::InformationType>(qRound(json.value("m_type").toDouble()));
|
||||
this->m_receivedTimestamp = QDateTime::fromString(json.value("m_receivedTimestamp").toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Type as string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user