refs #192, enable value objects for JSON:

* from/toJson methods
* jsonMembers where applicable
This commit is contained in:
Klaus Basan
2014-03-26 18:44:17 +01:00
parent 586e1e4053
commit 88fb9e8832
47 changed files with 910 additions and 276 deletions

View File

@@ -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
*/