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

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