mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
refs #192, enable value objects for JSON:
* from/toJson methods * jsonMembers where applicable
This commit is contained in:
@@ -276,6 +276,27 @@ namespace BlackMisc
|
||||
return BlackMisc::calculateHash(hashs, "PQ");
|
||||
}
|
||||
|
||||
/*
|
||||
* JSON Object
|
||||
*/
|
||||
template <class MU, class PQ> QJsonObject CPhysicalQuantity<MU, PQ>::toJson() const
|
||||
{
|
||||
QJsonObject json;
|
||||
json.insert("value", QJsonValue(this->m_value));
|
||||
json.insert("unit", QJsonValue(this->m_unit.getSymbol()));
|
||||
return json;
|
||||
}
|
||||
|
||||
/*
|
||||
* JSON Object
|
||||
*/
|
||||
template <class MU, class PQ> void CPhysicalQuantity<MU, PQ>::fromJson(const QJsonObject &json)
|
||||
{
|
||||
const QString unitSymbol = json.value("unit").toString();
|
||||
this->setUnitBySymbol(unitSymbol);
|
||||
this->m_value = json.value("value").toDouble();
|
||||
}
|
||||
|
||||
/*
|
||||
* metaTypeId
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user